首页 > 其他分享 >wireshark添加address sanitizer参数编译

wireshark添加address sanitizer参数编译

时间:2023-02-18 15:33:05浏览次数:62  
标签:Capture .. fsanitize leak sanitizer address wireshark

原文地址:https://www.cnblogs.com/liqinglucky/p/wireshark_memory_check.html

ubuntu系统wireshark源码编译文中已经会编译wireshark了。现在对wireshark的CMakeLists.txt中添加内存检测工具address sanitizer。这样就可以对wireshark程序代码做内存检测功能。

一 添加编译参数

改动很简单,只需在wireshark的CMakeLists.txt中添加address sanitizer编译参数

add_compile_options(-fsanitize=address -fsanitize-recover=all -fsanitize=leak) 
add_link_options(-fsanitize=address -fsanitize-recover=all -fsanitize=leak) 

git diff如下

wireshark-4.0.2# ls
CMakeLists.txt                  

wireshark-4.0.2# git diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 092dc7b..a9cad7a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1452,6 +1452,9 @@ if (QT_FOUND)
        endif()
 endif()

+add_compile_options(-fsanitize=address -fsanitize-recover=all -fsanitize=leak)
+add_link_options(-fsanitize=address -fsanitize-recover=all -fsanitize=leak)
+
 if(ENABLE_CHECKHF_CONFLICT)
        set(ENABLE_CHECK_FILTER 1)
 endif()

然后编译。

二 测试内存检测功能

可以在wireshark源代码中加测试代码,也可以启动wireshark后,直接用窗口的关闭按钮退出窗口就会触发内存泄漏

测试日志如下:

wireshark-4.0.2/build# run/wireshark
 ** (wireshark:472217) 06:50:13.504868 [Capture MESSAGE] -- Capture Start ...
 ** (wireshark:472217) 06:50:14.219331 [Capture MESSAGE] -- Capture started
 ** (wireshark:472217) 06:50:14.219555 [Capture MESSAGE] -- File: "/tmp/wireshark_any57OV01.pcapng"
 ** (wireshark:472217) 06:51:03.763713 [Capture MESSAGE] -- Capture Stop ...
 ** (wireshark:472217) 06:51:04.131232 [Capture MESSAGE] -- Capture stopped.

=================================================================
==472217==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 256 byte(s) in 1 object(s) allocated from:
    #0 0x7f9b05b65808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x7f9ae55692f4  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x212f4)

Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x7f9b05b67587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
    #1 0x55d8a024e8e3 in FunnelStatistics::FunnelStatistics(QObject*, CaptureFile&) /var/lte/wireshark/wireshark-4.0.2/ui/qt/funnel_statistics.cpp:122

Indirect leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x7f9b05b65a06 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:153
    #1 0x7f9ae556993c  (/lib/x86_64-linux-gnu/libfontconfig.so.1+0x2193c)

SUMMARY: AddressSanitizer: 296 byte(s) leaked in 3 allocation(s).

标签:Capture,..,fsanitize,leak,sanitizer,address,wireshark
From: https://www.cnblogs.com/liqinglucky/p/wireshark_memory_check.html

相关文章

  • 【网络】Wireshark分析RST消息
    文章目录    前言    1、定义:    2、有三个条件可以产生RST:    3、说明    4、RST数据报文产生情况        1......
  • 回送地址(Loopback Address)
    回送地址(LoopbackAddress)是本机回送地址(127.X.X.X),即主机IP堆栈内部的IP地址,主要用于网络软件测试以及本地机进程间通信。因此,无论什么程序,一旦使用回送地址发送数据,协议软......
  • 使用Wireshark捕捉USB通信数据
    使用Wireshark捕捉USB通信数据USB,是英文UniversalSerialBus(通用串行总线)的缩写,而其中文简称为“通串线”,是一个外部总线标准,用于规范电脑与外部设备的连接和通讯。USB接......
  • Sanitizers使用介绍
    Sanitizersers是一个工具集合,由google开发并开源,项目地址sanitizers。Sanitizers包括系列工具:AddressSanitizer,检测内存访问问题MemorySanitizer,检测未初始化内存问题......
  • Why is address space allocation granularity 64KB?
    Whyisaddressspaceallocationgranularity64KB?RaymondChen October8th,20030 0YoumayhavewonderedwhyVirtualAllocallocatesmemoryat64K......
  • ARP(Address Resolution Protocol) Packet
    AddressResolutionProtocolTheAddressResolutionProtocol(ARP)isacommunicationprotocolusedfordiscoveringthelinklayeraddress,suchasaMACaddres......
  • wireshark抓包教程详解
    https://blog.csdn.net/lixinkuan328/article/details/122985439 1、打开wireshark 2、选择菜单栏上Capture->Option,勾选WLAN网卡(这里需要根据各自电脑网卡使用情......
  • Wireshark 过滤规则
    Wireshark有两种用途的过滤器,分别是捕捉过滤器和显示过滤器。使用捕捉过滤器时,只会捕捉相关的数据,其他数据不予抓取;使用显示过滤器时,会捕捉所有的数据,但只呈现相关内容的数......
  • wireshark过滤器
    一:过滤器使用wireshark工具抓包,如果使用默认配置,会得到大量的数据,所以我们就很难找到我们要分析的封包数据。所以使用wireshark过滤器就显得尤为重要。wireshark过滤器......
  • 关于nginx-启动报错nginx: [emerg] socket() [::]:80 failed (97: Address family not
    今天在一台服务器上使用yum安装了nginx,然后启动报错:nginx:[emerg]socket()[::]:80failed(97:Addressfamilynotsupportedbyprotocol)先说一下环境,OSRelease:......