New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
segfault when trying to print out memory information (-showmeminfo) #85
Comments
The memory leak is a false-positive caused by running the sweep before global destructors finish. The console prompt added by btb is freed, but only after the sweep flags it as a leak. The crash is strange. It looks like it would be from |
I have to investigate this deeper. I checked with Valgrind and I found some messages that hint towards the issue may be related to PhysFS itself. Which is strange since PhysFS didn't update for a long time. Which then again may be the root of the issue - the package hasn't been recompiled since 2003 so it may have some dependency issues. I'll continue investigating and see what I can find. |
Valgrind says that the call to |
I think the flow is:
Removing the force-free in |
mem_display_blocks runs before global destructors, so it reports as leaked any memory which is managed by a global scope object with a destructor. If mem_display_blocks calls mem_free, and the destructor later calls mem_free, a double-free results, and usually leads to a crash. Even if the memory were actually leaked, freeing it does not help because the program will exit soon anyway. Reported-by: zico <#85>
Checked this again and the segfault is gone for me. The game still shows one un-freed block but I think this is not critical:
|
As I said above, I think this is a bogus report caused by running the sweep before global destructors finish. Memory allocated by the |
I noticed that D2X shows a memory block which left unfreed at the end of the game. So I wanted to trace this using -showmeminfo. Compiled the game with debug=1 and using the argument, the game segfaults upon exit.
bt:
Warning: MEM: 1 blocks were left allocated!
MEM_FREE_NOMALLOC: An attempt was made to free a ptr that wasn't
allocated with mem.h included.
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff63e1a2d in __memcpy_avx_unaligned () from /usr/lib/libc.so.6
(gdb) bt
The text was updated successfully, but these errors were encountered: