C,Valgrind自由,因为没有任何malloc的大分配

时间:2019-04-11 16:15:39

标签: c memory valgrind

我正在写一个shell,由于valgrind无法正常运行,我无法执行内存检查。

我遇到这样的错误(自己杀死):

==19703== Memcheck, a memory error detector
==19703== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==19703== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==19703== Command: ./tmpsh
==19703==
--19703-- run: /usr/bin/dsymutil "./tmpsh"
==19703== Warning: set address range perms: large range [0xffffffff000, 0x120000000000) (defined)
==19703== Warning: set address range perms: large range [0x140000000000, 0x200000000000) (defined)
==19703== Warning: set address range perms: large range [0x120000000000, 0x140000000000) (noaccess)
[1]    19703 killed     valgrind --leak-check=yes ./tmpsh

它似乎在某处分配了很大的空间,我能够使用如下代码生成类似的错误消息。

#include <stdlib.h>
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>


struct  test
{
    void    *val;
    void    *val1;
    void    *val2;
    void    *val3;

};

int     main(int argc, char **argv)
{
    int x;
    char    *ptr;

    x = 0;
    while (x++ < 500)
    {
        ptr = malloc(sizeof(struct test) * UINT_MAX);
        printf("%p\n", ptr);
        x++;
    }
    return (0);
}

具有类似valgrind的输出:

==22340== Memcheck, a memory error detector
==22340== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==22340== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==22340== Command: ./a.out
==22340==
==22340== Syscall param msg->desc.port.name points to uninitialised byte(s)
...
ImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) (in /usr/lib/dyld)
==22340==  Address 0x10488bc8c is on thread 1's stack
==22340==  in frame #2, created by task_set_special_port (???:)
==22340==
==22340== Warning: set address range perms: large range [0x259c3a040, 0x2259c3a020) (undefined)
0x259c3a040
==22340== Warning: set address range perms: large range [0x2259c3b040, 0x4259c3b020) (undefined)
0x2259c3b040
...

但是在这种情况下,我的程序正在运行,因为我可以使用printf。

因此,我删除了所有代码,并使用了类似的主程序以避免malloc,但仍然遇到相同的错误:

int     main(int argc, char **argv)
{
    t_hist  *history;
    int     status;

        status = 0;
    return (status);
}

我的项目包含大量文件,并与单个静态(.a)库链接。

这个巨大的分配可以来自valgrind吗?可能来自我的项目架构吗? 感谢您的帮助

几分钟后

完整日志,但我自己没有杀死

==22900== Memcheck, a memory error detector
==22900== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==22900== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==22900== Command: ./tmpsh
==22900==
==22900== Warning: set address range perms: large range [0xffffffff000, 0x120000000000) (defined)
==22900== Warning: set address range perms: large range [0x140000000000, 0x200000000000) (defined)
==22900== Warning: set address range perms: large range [0x120000000000, 0x140000000000) (noaccess)
==22900== Warning: set address range perms: large range [0x600000000000, 0x640000003000) (noaccess)
==22900== Conditional jump or move depends on uninitialised value(s)
==22900==    at 0x10018CFAD: __sanitizer::StackDepotReverseMap::StackDepotReverseMap() (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x100184FC8: __sanitizer::RegisterCommonFlags(__sanitizer::FlagParser*, __sanitizer::CommonFlags*) (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x10019C6DE: handleFunctionTypeMismatch(__ubsan::FunctionTypeMismatchData*, unsigned long, __ubsan::ReportOptions) (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x10019B2E6: handleShiftOutOfBoundsImpl(__ubsan::ShiftOutOfBoundsData*, unsigned long, unsigned long, __ubsan::ReportOptions) (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x10019C9A8: __ubsan_handle_nonnull_return_v1 (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x10017DC0D: wrap__Znam (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x1001764DF: __sanitizer_annotate_contiguous_container (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x101411846: map_images_nolock (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x101424FE8: objc_object::sidetable_retainCount() (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x10003E03B: dyld::notifyBatchPartial(dyld_image_states, bool, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*), bool, bool) (in /usr/lib/dyld)
==22900==    by 0x10003E255: dyld::registerObjCNotifiers(void (*)(unsigned int, char const* const*, mach_header const* const*), void (*)(char const*, mach_header const*), void (*)(char const*, mach_header const*)) (in /usr/lib/dyld)
==22900==    by 0x10105F00A: _dyld_objc_notify_register (in /usr/lib/system/libdyld.dylib)
==22900==
==22900== Conditional jump or move depends on uninitialised value(s)
==22900==    at 0x10018CFAD: __sanitizer::StackDepotReverseMap::StackDepotReverseMap() (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x10018508D: __sanitizer::RegisterCommonFlags(__sanitizer::FlagParser*, __sanitizer::CommonFlags*) (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x10019C6DE: handleFunctionTypeMismatch(__ubsan::FunctionTypeMismatchData*, unsigned long, __ubsan::ReportOptions) (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x10019B2E6: handleShiftOutOfBoundsImpl(__ubsan::ShiftOutOfBoundsData*, unsigned long, unsigned long, __ubsan::ReportOptions) (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x10019C9A8: __ubsan_handle_nonnull_return_v1 (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x10017DC0D: wrap__Znam (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x1001764DF: __sanitizer_annotate_contiguous_container (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x101411846: map_images_nolock (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x101424FE8: objc_object::sidetable_retainCount() (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x10003E03B: dyld::notifyBatchPartial(dyld_image_states, bool, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*), bool, bool) (in /usr/lib/dyld)
==22900==    by 0x10003E255: dyld::registerObjCNotifiers(void (*)(unsigned int, char const* const*, mach_header const* const*), void (*)(char const*, mach_header const*), void (*)(char const*, mach_header const*)) (in /usr/lib/dyld)
==22900==    by 0x10105F00A: _dyld_objc_notify_register (in /usr/lib/system/libdyld.dylib)
==22900==
==22900== Invalid read of size 1
==22900==    at 0x100120809: __asan::asan_calloc(unsigned long, unsigned long, __sanitizer::BufferedStackTrace*) (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x100176130: __asan_poison_stack_memory (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x101414054: freeBuckets(NXHashTable*, int) (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x101413F15: _NXHashRehashToCapacity (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x101413E50: NXHashInsert (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x101413B0D: NXCreateHashTableFromZone (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x1014139CE: NXCreateHashTable (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x1014138CE: NXCreateMapTableFromZone (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x101413878: NXCreateMapTableFromZone (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x101412350: __sel_registerName(char const*, int, int) (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x101412062: sel_init (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x1014119CA: map_images_nolock (in /usr/lib/libobjc.A.dylib)
==22900==  Address 0x104a001a0 is 16 bytes before a block of size 24 alloc'd
==22900==    at 0x1000CEDB5: malloc_zone_calloc (in /Users/simrossi/.brew/Cellar/valgrind/3.13.0/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==22900==    by 0x101413E13: NXHashInsert (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x101413B0D: NXCreateHashTableFromZone (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x1014139CE: NXCreateHashTable (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x1014138CE: NXCreateMapTableFromZone (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x101413878: NXCreateMapTableFromZone (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x101412350: __sel_registerName(char const*, int, int) (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x101412062: sel_init (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x1014119CA: map_images_nolock (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x101424FE8: objc_object::sidetable_retainCount() (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x10003E03B: dyld::notifyBatchPartial(dyld_image_states, bool, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*), bool, bool) (in /usr/lib/dyld)
==22900==    by 0x10003E255: dyld::registerObjCNotifiers(void (*)(unsigned int, char const* const*, mach_header const* const*), void (*)(char const*, mach_header const*), void (*)(char const*, mach_header const*)) (in /usr/lib/dyld)
==22900==
=================================================================
==22900==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x000104a001b0 in thread T0
==22900== Conditional jump or move depends on uninitialised value(s)
==22900==    at 0x10018CFAD: __sanitizer::StackDepotReverseMap::StackDepotReverseMap() (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x10019BFCC: handleFloatCastOverflow(void*, unsigned long, __ubsan::ReportOptions) (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x10019BAA1: __ubsan_handle_missing_return (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x100193D74: __sanitizer_reset_coverage (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x10019AEA9: handleShiftOutOfBoundsImpl(__ubsan::ShiftOutOfBoundsData*, unsigned long, unsigned long, __ubsan::ReportOptions) (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x10019A827: handleNegateOverflowImpl(__ubsan::OverflowData*, unsigned long, __ubsan::ReportOptions) (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x100128188: __asan::ErrorStringFunctionMemoryRangesOverlap::Print() (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x10017B5C0: __asan::SetMallocContextSize(unsigned int) (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x10017A70C: __asan::AsanInitInternal() (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x100176130: __asan_poison_stack_memory (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x101414054: freeBuckets(NXHashTable*, int) (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x101413F15: _NXHashRehashToCapacity (in /usr/lib/libobjc.A.dylib)
==22900==
==22900== Conditional jump or move depends on uninitialised value(s)
==22900==    at 0x10019C1E7: handleFloatCastOverflow(void*, unsigned long, __ubsan::ReportOptions) (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x10019BAA1: __ubsan_handle_missing_return (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x100193D74: __sanitizer_reset_coverage (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x10019AEA9: handleShiftOutOfBoundsImpl(__ubsan::ShiftOutOfBoundsData*, unsigned long, unsigned long, __ubsan::ReportOptions) (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x10019A827: handleNegateOverflowImpl(__ubsan::OverflowData*, unsigned long, __ubsan::ReportOptions) (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x100128188: __asan::ErrorStringFunctionMemoryRangesOverlap::Print() (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x10017B5C0: __asan::SetMallocContextSize(unsigned int) (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x10017A70C: __asan::AsanInitInternal() (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x100176130: __asan_poison_stack_memory (in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib)
==22900==    by 0x101414054: freeBuckets(NXHashTable*, int) (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x101413F15: _NXHashRehashToCapacity (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x101413E50: NXHashInsert (in /usr/lib/libobjc.A.dylib)
==22900==
atos cannot load symbols for process 22900.
==22900==WARNING: Can't read from symbolizer at fd 5
atos cannot load symbols for process 22900.
==22900==WARNING: Can't read from symbolizer at fd 5
atos cannot load symbols for process 22900.
==22900==WARNING: Can't read from symbolizer at fd 5
atos cannot load symbols for process 22900.
==22900==WARNING: Can't read from symbolizer at fd 5
==22900==WARNING: Failed to use and restart external symbolizer!
    #0 0x100176066 in wrap_free (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x59066)
atos cannot load symbols for process 22900.
    #1 0x101414054 in freeBuckets(NXHashTable*, int) (/usr/lib/libobjc.A.dylib:x86_64h+0x4054)
    #2 0x101413f15 in _NXHashRehashToCapacity (/usr/lib/libobjc.A.dylib:x86_64h+0x3f15)
    #3 0x101413e50 in NXHashInsert (/usr/lib/libobjc.A.dylib:x86_64h+0x3e50)
    #4 0x101413b0d in NXCreateHashTableFromZone (/usr/lib/libobjc.A.dylib:x86_64h+0x3b0d)
    #5 0x1014139ce in NXCreateHashTable (/usr/lib/libobjc.A.dylib:x86_64h+0x39ce)
    #6 0x1014138ce in NXCreateMapTableFromZone (/usr/lib/libobjc.A.dylib:x86_64h+0x38ce)
    #7 0x101413878 in NXCreateMapTable (/usr/lib/libobjc.A.dylib:x86_64h+0x3878)
    #8 0x101412350 in __sel_registerName(char const*, int, int) (/usr/lib/libobjc.A.dylib:x86_64h+0x2350)
    #9 0x101412062 in sel_init (/usr/lib/libobjc.A.dylib:x86_64h+0x2062)
    #10 0x1014119ca in map_images_nolock (/usr/lib/libobjc.A.dylib:x86_64h+0x19ca)
    #11 0x101424fe8 in map_images (/usr/lib/libobjc.A.dylib:x86_64h+0x14fe8)
    #12 0x10003e03b  (<unknown module>)
    #13 0x10003e255  (<unknown module>)
    #14 0x10105f00a in _dyld_objc_notify_register (/usr/lib/system/libdyld.dylib:x86_64+0x300a)
    #15 0x101411074 in _objc_init (/usr/lib/libobjc.A.dylib:x86_64h+0x1074)
    #16 0x100ff268d in _os_object_init (/usr/lib/system/libdispatch.dylib:x86_64+0x168d)
    #17 0x100ff263a in libdispatch_init (/usr/lib/system/libdispatch.dylib:x86_64+0x163a)
    #18 0x100f069d5 in libSystem_initializer (/usr/lib/libSystem.B.dylib:x86_64+0x19d5)
    #19 0x10004ea1a  (<unknown module>)
    #20 0x10004ec1d  (<unknown module>)
    #21 0x10004a4a9  (<unknown module>)
    #22 0x10004a440  (<unknown module>)
    #23 0x100049523  (<unknown module>)
    #24 0x1000495b8  (<unknown module>)
    #25 0x10003b433  (<unknown module>)
    #26 0x10003f8c5  (<unknown module>)
    #27 0x10003a248  (<unknown module>)
    #28 0x10003a035  (<unknown module>)

Address 0x000104a001b0 is a wild pointer.
SUMMARY: AddressSanitizer: bad-free (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x59066) in wrap_free
==22900== Invalid read of size 4
==22900==    at 0x101416E7A: class_createInstance (in /usr/lib/libobjc.A.dylib)
==22900==    by 0x100FF276A: _os_object_alloc_realized (in /usr/lib/system/libdispatch.dylib)
==22900==    by 0x1013C8A73: xpc_dictionary_create (in /usr/lib/system/libxpc.dylib)
==22900==    by 0x1013CC0AD: _bootstrap_create_request (in /usr/lib/system/libxpc.dylib)
==22900==    by 0x1013CBE6E: bootstrap_look_up3 (in /usr/lib/system/libxpc.dylib)
==22900==    by 0x1013CBE10: bootstrap_look_up2 (in /usr/lib/system/libxpc.dylib)
==22900==    by 0x101348A81: ___notify_lib_init_block_invoke (in /usr/lib/system/libsystem_notify.dylib)
==22900==    by 0x100FF28FB: _dispatch_client_callout (in /usr/lib/system/libdispatch.dylib)
==22900==    by 0x100FF28B8: dispatch_once_f (in /usr/lib/system/libdispatch.dylib)
==22900==    by 0x1013454F1: _notify_lib_init (in /usr/lib/system/libsystem_notify.dylib)
==22900==    by 0x101346386: notify_register_check (in /usr/lib/system/libsystem_notify.dylib)
==22900==    by 0x1013A4448: _os_trace_prefs_and_mode_refresh_slow (in /usr/lib/system/libsystem_trace.dylib)
==22900==  Address 0x10 is not stack'd, malloc'd or (recently) free'd
==22900==
ASAN:DEADLYSIGNAL
AddressSanitizer: nested bug in the same thread, aborting.
==22900==
==22900== HEAP SUMMARY:
==22900==     in use at exit: 208 bytes in 7 blocks
==22900==   total heap usage: 7 allocs, 0 frees, 208 bytes allocated
==22900==
[1]    22900 killed     valgrind --leak-check=yes ./tmpsh

1 个答案:

答案 0 :(得分:0)

我正在使用-g -fsanitize=address标志进行编译。删除-fsanitize=address即可完成工作,并允许我正确使用valgrind。

如有任何解释,请随时添加详细信息。