-
|
Hello. Please help me with this phenomenon. I use KFR C API with my C code [1]. It works well, but, I found that there is 73,728 bytes of memory "leak" (and below, i'll mean this same amount of "leaked" bytes). Reduce this case to minimal reproduceable one, i found this one-liner with empty C code, which shows that "leak" occur not at C code itself, but at linker phase [2]: As you may note, it is impossible at this stage to tell if it's something wrong with KFR C API, as the command contains other library ( With further research, i was able to found these commands. It shows "leak" with Compiling with these sanitize switches also reveals memory "leak" with KFR's provided Expected results: No errors printed. Obtained results: still reachable: 73,728 bytes So i can think that something happens with The native (C++) versions of KFR examples, are all clear. The "leak"s are quoted, because i found no way so far to distinguish possible real leak from, either, possible oversensitive I have fresh Archlinux, 6.19.9-arch1-1 #1 SMP PREEMPT_DYNAMIC, Intel x86_64, two desktops tested. I've tested Thanks! [1] https://github.com/twonoise/jasmine-sa |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
I would treat this as “not proven to be a leak” until Valgrind shows
Two things in your commands make the signal harder to read: gcc -fsanitize=leak ... && valgrind ./a.out
gcc -fsanitize=undefined ... && valgrind ./a.outThat mixes Valgrind with sanitizer runtimes. The sanitizer runtime itself changes process startup/shutdown behavior and can allocate persistent state. I would run these as separate experiments: valgrind --leak-check=full --show-leak-kinds=all --num-callers=40 /tmp/test
LSAN_OPTIONS=verbosity=1:report_objects=1 ./a.outIf Valgrind still only reports For a C API leak test, the stronger reproducer is a loop that repeatedly creates and destroys the same KFR object/call path in one long-lived process, then watch RSS or LSan at shutdown. A fixed 73,728 bytes after loading |
Beta Was this translation helpful? Give feedback.
-
|
Thanks so much @ZX41R for explaining. Sadly i am not expirienced in modern debugging, but try to learn using your suggestions.
Yes, it is.
Here is the problem, i am can't detect something similar (or not) to "the first non-libc frame" at Valgrind's output. It says "73,728 bytes in 1 blocks..." following by trace which i can get any logical meaning from. (There is no 'libc' word at it though).
I am do not know the place where i can know if "whether the library is actually being loaded" using this switch; visually there is no any difference. The ultimate problem is that "leak" occur, afaicu, not in the code (as it is empty) but at linker/loader stage, so all various debug tools/ways i can find via web search, are not applicable. (trying to find Valgrind alternative to cross-check both of these, is failed).
Looping is not reproduceable, as i am not create any KFR objects in empty code. Should i elaborate more complex case as such? As i thought that code should be shortest possible yet revealing the "leak", which is empty body.
Yes, it is always exactly this amount. I will research it more today. Thanks! |
Beta Was this translation helpful? Give feedback.
-
|
So i've conducted multiple random tests and found something. If library is created like this: (Here i assume ...then "problem" is "solved": As default one is one may note that difference is with Btw, one may also note other things, like duplicated In my case it also work as simple as Please do not use these "fixes" on production machines, unless you (unlike me) know what you are doing. Thank you for great software. |
Beta Was this translation helpful? Give feedback.
I would treat this as “not proven to be a leak” until Valgrind shows
definitely lostorindirectly lostwith a useful allocation stack.still reachablemeans there is still a live root to the allocation when the process exits. That is common for shared-library constructors, audio backends, sanitizer runtimes, one-time FFT tables, TLS caches, andatexitcleanup paths. It is noisy in exactly the kind of test you are running: an empty program whose only job is to load DSOs and then exit.Two things in your commands make the signal harder to read:
That mixes Valgrind with sanitizer runtimes. The sanit…