-
Notifications
You must be signed in to change notification settings - Fork 90
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
Linux Dota 2 Metamod segfault on shutdown #42
Comments
This has been a long-standing issue since porting MM:S to Source 2. I've not been able to find the cause yet. |
Ah, that's sad. Alright, I'll try to find what causing that myself as well |
Good luck! Given where it crashes, my best guess is that it's due to some change (in MM:S for S2, or in vstdlib) with ConVar/ConCommand registration. I think that's the only real thing we use from there in vstdlib, and they do get cleaned up at shutdown. |
Fiddling around with shutdown sequence made me sure that you're right, there's something wrong with ConVar unregs. Best trace i had so far looks like this:
I'll keep looking |
Looks like I do understand why unregs might cause segfaults but I really don't understand why unloading gamedll_lib (and only that, unloading metamod doesn't affect shutdown seq) is failing. Have any ideas? Meanwhile I'll keep reversing vstdlib |
Great catch! It's still not fully making sense since the issue was present back when the Mac binaries still had symbols, where the param types were visible. I also don't see a second param being used/present in the disassembly of the current bin. However, can't argue with results! As for the mm_UnloadLibrary issue, I'll have to look into it. |
My disassembly looks something like this:
vstdlib starting address is 0x7FFFFCB40000 |
The first param passed should be the In the disassembly there, near the start, you can see that if it was actually using 0/NULL as iUnknown, it would be segfaulting on this line. |
Hmm, you're right. Why does it work then? |
That's the mystery! |
Hm, I found something confusing. If you change everything related to convar flags in convar.cpp/.h (tier1) from int to int64 it also stops segfaults from happening. Although unloading gamedll_lib still fails. |
That's indeed confusing, but I'll have to try it out. The main ABI points should be the virtual functions and the class members, all which do all use int64 for flags as far as I can tell. The rest should not matter, although it's probably still good idea to update them regardless for consistency. |
It still crashed for me after updating those. I did look further into the actual crash however, and it's in CCvar::RemoveSplitScreenConVars, suggesting that there still is an issue with flags somewhere (such as a ConVar that MM:S creates mistakenly getting the FCVAR_SS set on it, possibly due to uninitialized memory in flags. |
…ource#42) Still needs tier1 recompile.
I updated the flags var in all usages I could find in the latest commit. As a sanity check, could you compare to your files to see if I missed anywhere? I'm still not yet convinced it's the fix for this issue, but needed to be done regardless. |
You've missed all ConVar_Register's and \tier1\convar.cpp#40, \tier1\convar.cpp#1150. At least that's how it is in my files. |
Ah ha! Thank you. That makes sense and does explain the crash perfectly. I can confirm the other issue now as well and will look into that. |
Can you explain why that happens? I'm curious what exactly goes wrong there |
I'm not sure yet. It's possible that in Source 2, some additional function from server.dll/so gets called after IAppSystem::Shutdown. |
I'm probably about to give up on this for the day, but the issue does seem like it could still be related to ConVars. On Windows (using the win32 build), this is the stack trace I'm getting.
The game's server.dll is at 21480000 - 23438000, and the top address in the stack isn't in any module. The next function down is ConVar::ChangeStringValue. I'm not sure yet what to make of any of that, but thought I'd share the info I have so far. Edit: looks like it's crashing on calling a change callback. Not sure if ConVar-local or Global ones. |
I realized that in one of the plugins I had loaded, there was a global ConVar change callback installed (and maybe you do too?). If I remove that, it's back to crashing in CCvar::RemoveSplitScreenConVars again.
|
Yes, I had global change callback as well but I've disabled it while I was looking at cvar crashes. |
With the global change callback disabled, do you still get a crash in vstdlib at shutdown? (Presumably the same CCvar::RemoveSplitScreenConVars crash I see) |
Yes I do |
Any progress? |
Not really, sorry. Got sidetracked with other things. I'll try to get back to it later this week. |
If I remove all MM plugins backtrace becomes smaller
At that point I thought it's dota issue, but if I remove metamod completely dota starts and stops properly without segfaulting.
Tested on WSL Ubuntu and Debian 9 Minimal.
The text was updated successfully, but these errors were encountered: