ssbssa / heob

Detects buffer overruns and memory leaks.
Boost Software License 1.0
155 stars 25 forks source link

question: the latest release is in year 2019? #31

Closed asmwarrior closed 6 months ago

asmwarrior commented 7 months ago

Hi, I just try to find some memory leak detect tool, so I goes to your project.

But I found that the latest release is from year 2019. So, if people has to clone your git repo and build the tool by himself? I'm mainly use mingw/gcc.

Thanks.

ssbssa commented 7 months ago

Yes, I planned to do a new release for a while now, but never got to it.

But you don't necessarily have to build the latest git version yourself, there is a CI build available here: heob.7z (This link is hidden in the main page in the small icon beside the 'build passing' logo of the CI)

asmwarrior commented 7 months ago

Yes, I planned to do a new release for a while now, but never got to it.

But you don't necessarily have to build the latest git version yourself, there is a CI build available here: heob.7z (This link is hidden in the main page in the small icon beside the 'build passing' logo of the CI)

OK, I'm glad to see there is a CI built version. But you should mention that in the homepage, because people does not know that unless they asked like me. Thanks.

ssbssa commented 7 months ago

If you've tried it, I would be interested to hear about your experience of using heob, the good and the bad stuff.

asmwarrior commented 7 months ago

OK, as a first time user or beginner of the heob, I have some comments:

1, in the home page, I think you should explain what the option means:

Usage: heob64 [OPTION]... APP [APP-OPTION]...

    -oX    heob output [1]
    -vX    svg output
    -PX    show process ID and wait [0]
    -cX    create new console [0]
    -pX    page protection [1]
    -fX    freed memory protection [0]
    -hX    handle exceptions [1]
    -DX    show exception details [0]
    -FX    show full path [0]
    -lX    show leak details [1]
    -kX    control leak recording [0]
    -IX    sampling profiler interval [0]
    -H[H]  show full help

heap-observer 3.2-dev-136 (64bit)

For example, "show leak details", what does this option mean? I don't know. As I know, a svg file is a image file, what does the svg file used for? I don't know, maybe a sample svg file will demonstrate the details.

2, people need to know where to download the dwarfstack.dll, it should be mentioned in the home page here: https://github.com/ssbssa/dwarfstack/releases

3, what doe the line information mean, for example, I have such log:

F:\code\test-prep\tpp\samples\advanced\bin\Debug>heob64.exe -F advanced.exe
...
...
unhandled exception code: 0xC0000005 (ACCESS_VIOLATION)
  exception on: '1 [14184]'
    0x00007FF647640000   advanced.exe
      0x00007FF647642EA4   tpp.c:2051:4 [TPPFile_Destroy]
      0x00007FF64764CDE5   tpp.c:5509:3 [cleanup_keyword]
      0x00007FF64764D0DD   tpp.c:5558:4 [destroy_keyword_map]
      0x00007FF64764E8FD   tpp.c:6263:2 [TPPLexer_Quit]
      0x00007FF647641840   main.c:84:2 [main]
      0x00007FF6476412ED   crtexe.c:267:15 [__tmainCRTStartup]
      0x00007FF647641405   crtexe.c:188:9 [mainCRTStartup]
  read access violation at 0x000001438AB70F50
  near protected area of 0x000001438AB50FF0 (size 16, offset +130912)
  allocated on: (#8) '1 [14184]'
                           [realloc]
    0x00007FF647640000   advanced.exe
      0x00007FF647650A01   tpp.c:7039:30 [TPPLexer_AddIncludePath]
      0x00007FF6476415EE   main.c:36:7 [main]
      0x00007FF6476412ED   crtexe.c:267:15 [__tmainCRTStartup]
      0x00007FF647641405   crtexe.c:188:9 [mainCRTStartup]

F:\code\test-prep\tpp\samples\advanced\bin\Debug>

what does the "main.c:36:7" mean? line 36 and column 7? Is it possible to show the allocated(leaked) memory size?

Thanks.

ssbssa commented 7 months ago

1, in the home page, I think you should explain what the option means:

You can get more info of the heob help with -HH (though I doubt it will clear up all questions). I see you set the -F option, you probably wanted -F1 instead, since without a number it will be zero again.

Note that the qt-creator help also has info for some parameter here. I don't know how many people really use heob, but the ones that do, probably use it via qt-creator.

2, people need to know where to download the dwarfstack.dll, it should be mentioned in the home page here: https://github.com/ssbssa/dwarfstack/releases

Also a fair point (in qt-creator you get an info dialog giving you this link).

what does the "main.c:36:7" mean? line 36 and column 7?

Yes.

Is it possible to show the allocated(leaked) memory size?

If the program crashed, like in this case, no. Is this a program that should crash, because I just tried the tpp/samples/advanced/a.exe with heob, and it doesn't crash for me.

asmwarrior commented 7 months ago

1, in the home page, I think you should explain what the option means:

You can get more info of the heob help with -HH (though I doubt it will clear up all questions).

Oh, using the -HH, I see a lot more help. Thanks.

I see you set the -F option, you probably wanted -F1 instead, since without a number it will be zero again.

OK, let me have a look, I don't know that there need an extra option after the -F before. Thanks.

Note that the qt-creator help also has info for some parameter here. I don't know how many people really use heob, but the ones that do, probably use it via qt-creator.

Oh, I see qt-creator shows good documents about how to use heob, I'm mainly use wxWidgets, so maybe I(or someone) will implement a same feature inside the Code::Blocks. Detecting memory leak is a very important feature.

Is it possible to show the allocated(leaked) memory size?

If the program crashed, like in this case, no. Is this a program that should crash, because I just tried the tpp/samples/advanced/a.exe with heob, and it doesn't crash for me.

I tried to use heob to catch a memory leak error in tpp's code, but I feel it is hard for me. Here is the detailed issue about this crash: Crash in cleanup_keyword · Issue #4 · GrieferAtWork/tpp, luckily, the author has fixed that bug. If you would like to reproduce this crash bug, you can simply change this line:

https://github.com/GrieferAtWork/tpp/blob/800e2176b8f33fe67d14a6a1ddb89c4c284890cf/samples/advanced/main.c#L47

to:

    TPPLexer_PushFileInherited(file);

I'm not sure heob can help to detect such "write-after-free" bug mentioned in Griefer's comment: https://github.com/GrieferAtWork/tpp/issues/4#issuecomment-1949964372

ssbssa commented 7 months ago

I tried to use heob to catch a memory leak error in tpp's code, but I feel it is hard for me. Here is the detailed issue about this crash: Crash in cleanup_keyword · Issue #4 · GrieferAtWork/tpp, luckily, the author has fixed that bug. If you would like to reproduce this crash bug, you can simply change this line:

https://github.com/GrieferAtWork/tpp/blob/800e2176b8f33fe67d14a6a1ddb89c4c284890cf/samples/advanced/main.c#L47

to:

  TPPLexer_PushFileInherited(file);

Yes, that's helpful, with that change I get the same output as you.

I'm not sure heob can help to detect such "write-after-free" bug mentioned in Griefer's comment: GrieferAtWork/tpp#4 (comment)

Yes, heob can help with "write-after-free" bugs, but you need to enable option -f1, then you get this result:

unhandled exception code: 0xC0000005 (ACCESS_VIOLATION)
  exception on: '1 [11884]'
    0x000000013F820000   a.exe
      0x000000013F823032   tpp.c:2051:4 [TPPFile_Destroy]
      0x000000013F82CF78   tpp.c:5509:3 [cleanup_keyword]
      0x000000013F82D270   tpp.c:5558:4 [destroy_keyword_map]
      0x000000013F82EA8B   tpp.c:6263:2 [TPPLexer_Quit]
      0x000000013F8219E8   main.c:84:2 [main]
      0x000000013F821430   crtexe.c:345:15 [__tmainCRTStartup]
      0x000000013F8215B5   crtexe.c:220:9 [mainCRTStartup]
  read access violation at 0x0000000000740F50
  freed block 0x0000000000740F50 (size 176, offset 0)
  allocated on: (#11) '1 [11884]'
                           [malloc]
    0x000000013F820000   a.exe
      0x000000013F823891   tpp.c:2269:29 [TPPFile_OpenStream]
      0x000000013F824854   tpp.c:2686:11 [TPPFile_Open]
      0x000000013F831762   tpp.c:7283:12 [open_normal_file]
      0x000000013F831A00   tpp.c:7344:12 [TPPLexer_OpenFile]
      0x000000013F8217D8   main.c:41:25 [main]
      0x000000013F821430   crtexe.c:345:15 [__tmainCRTStartup]
      0x000000013F8215B5   crtexe.c:220:9 [mainCRTStartup]
  freed on: '1 [11884]'
                           [free]
    0x000000013F820000   a.exe
      0x000000013F82320D   tpp.c:2078:2 [TPPFile_Destroy]
      0x000000013F82CFF1   tpp.c:5513:4 [cleanup_keyword]
      0x000000013F82D270   tpp.c:5558:4 [destroy_keyword_map]
      0x000000013F82EA8B   tpp.c:6263:2 [TPPLexer_Quit]
      0x000000013F8219E8   main.c:84:2 [main]
      0x000000013F821430   crtexe.c:345:15 [__tmainCRTStartup]
      0x000000013F8215B5   crtexe.c:220:9 [mainCRTStartup]

So it shows you where this memory block was already freed on.

Note that heob has various modes, so if you want to catch this kind of errors, you should use -f1. But both -p1 and -f1 make the program use a lot of memory, and also slow it down quite a bit, so if you only want to look for memory leaks, then you probably want to disable them. And for memory leaks I also suggest using flame graph output in svg format, with -vleaks.svg.

asmwarrior commented 7 months ago

Wow, this tool is great! Thanks. Let me take some time to learn those various options. I think it could be nice if someone could write a simple tutorial about what kinds of bugs the heob can catch and using which options.

ssbssa commented 6 months ago

I finally made a new release: heob-4.0.