plog icon indicating copy to clipboard operation
plog copied to clipboard

ASAN: Direct leak of 100 byte(s) in 1 object(s) allocated from:

Open JohnSmithBH84 opened this issue 6 months ago • 1 comments

I’ve scanned plog with ASAN and it has triggered on plog/samples/HexDump/Main.cpp line 40. I'm not sure whether this is an actual issue, or whether code of plog is too sophisticated for ASAN to understand. Do you guys have any idea?

Project version

plog: master

Operating system

compiler: gcc (Debian 12.2.0-14) 12.2.0

Ubuntu 22.04.4 LTS Linux 5.15.0-125-generic #135-Ubuntu SMP Fri Sep 27 13:53:58 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

I did this

Launched plog/build/samples/HexDump/HexDump

I expected the following

No problem reported by ASAN

I got the following

plog/build/samples/HexDump/HexDump
2025-04-04 09:56:23.945 INFO  [1609] [main@28] v: 0a 00 00 00 14 00 00 00  1e 00 00 00 28 00 00 00  40 42 0f 00 80 84 1e 00  c0 c6 2d 00
2025-04-04 09:56:23.946 INFO  [1609] [main@29] v: 0a 00 00 00 14 00 00 00 1e 00 00 00 28 00 00 00 40 42 0f 00 80 84 1e 00 c0 c6 2d 00
2025-04-04 09:56:23.946 INFO  [1609] [main@30] v: 0a000000140000001e0000002800000040420f0080841e00c0c62d00
2025-04-04 09:56:23.946 INFO  [1609] [main@31] v: 0a 00 00 00|14 00 00 00|1e 00 00 00|28 00 00 00|40 42 0f 00|80 84 1e 00|c0 c6 2d 00
2025-04-04 09:56:23.946 INFO  [1609] [main@32] v: 0a00000014000000 1e00000028000000 40420f0080841e00 c0c62d00
2025-04-04 09:56:23.946 INFO  [1609] [main@35] s: 48 65 6c 6c 6f 21
2025-04-04 09:56:23.946 INFO  [1609] [main@38] arr: ff 00 00 00 ff 01 00 00  ff ff 00 00
2025-04-04 09:56:23.946 INFO  [1609] [main@41] p: be be be be be be be be  be be be be be be be be  be be be be be be be be  be be be be be be be be  be be be be be be be be  be be be be be be be be  be be be be be be be be  be be be be be be be be  be be be be be be be be  be be be be be be be be  be be be be be be be be  be be be be be be be be  be be be be

==1609==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 100 byte(s) in 1 object(s) allocated from:
    #0 0x7f3b3de1d9cf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x55832825a742 in main plog/samples/HexDump/Main.cpp:40

JohnSmithBH84 avatar Jun 10 '25 07:06 JohnSmithBH84

Hey @JohnSmithBH84,

The sample allocates memory void* p = malloc(100); and doesn't call free(). It's ok for the sample (as the process dies and frees all memory anyways) but I agree that it's better to have a sample without a leak to propagate best programming practices.

We'll fix that. Thank for the report!

SergiusTheBest avatar Jun 10 '25 13:06 SergiusTheBest