Open rbalint opened 4 years ago
I bisected the issue to commit 51e14c12b671a624a6b0a08aaadab053220a4c59.
Although the changes to DBstats.c are small, the change cannot be reverted just for that file to narrow the issue down, as the commit also removed the Load_Track function the code previously depended on. Unfortunately, this seems to be a symptom of deeper issues. When building that snapshot with ASan, I get a buffer overflow in a totally different place:
#0 0x7ffff76a4858 in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:164
#1 0x5555555aefda in Realloc /root/DAZZ_DB/DB.c:79
#2 0x5555555b7c4d in Trim_DB /root/DAZZ_DB/DB.c:800
#3 0x5555555ab6f6 in main /root/DAZZ_DB/DBstats.c:118
#4 0x7ffff69a5e49 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x27e49)
The DBstats code iterate through a linked list of tracks. Following the rework introduced in commit 51e14c12b671a624a6b0a08aaadab053220a4c59, the tracks are closed after being processed. After that the record stored in track is invalid because it has been freed, so accessing track->next is undefined. The problem is only visible with glibc 2.32 and later, due to the Safe-Linking mechanism added to fastbins and tcache (https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=a1a486d70ebcc47a686ff5846875eacad0940e41) which in that case prevent access to memory that has been freed.
I would recommend drop the Close_Track(db,track)
entry because:
While testing glibc 2.32 we discovered dazzdb crasing in Ubuntu CI: https://autopkgtest.ubuntu.com/packages/d/dazzdb/groovy/amd64
The root cause seems to be an invalid read, which can be detected even with glibc 2.31, but for some reason it does not end up in a crash. I've replaced the crashing command with
valgrind ...
: