-
Notifications
You must be signed in to change notification settings - Fork 480
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
Fix unloading of C plugins #1533
base: dev
Are you sure you want to change the base?
Conversation
I think this might be a bit more complicated than it seems at first. Let me first walk through what we want here (mostly to have this written down for myself, seems like you might already understand this): When PANDA goes to terminate an emulation because
We want to inform all the loaded plugins of the imminent shutdown by:
And finally clean up/unload plugin state, terminate the emulation, and exit. In #1313 (76b5d84) we fixed the case where a shutdown triggered from C/C++ wouldn't cause the It sounds like the issue you're seeing is that the I'm worried that there might be some race conditions or issues with the change you have here because the existing panda/panda/python/core/pandare/panda.py Lines 781 to 785 in 3787038
But there's a comment specifically about this method being used during shutdown:
Tracking that down, I see the end of the python logic driving emulation calls panda.panda_finish which ultimately returns execution to shutdown logic in vl.c here - but I don't see anything unloading plugins on this path - perhaps we should add this unload logic there instead? Lines 5088 to 5115 in 3787038
|
Thanks for the quick and detailed response! I read a bit more source code and now I'm less sure how everything is supposed to work :) My Python script loads a Rust plugin and calls If I understand what is happening correctly, the call to Your idea with unloading the plugins in vl.c is actually what is already happening. It's just hidden away in the call to Lines 229 to 235 in 3787038
However, that code actually never runs if you don't call So now I'm not sure what to do here. My code now works after adding a call to |
76b5d84 removed the direct call to
self.libpanda.panda_unload_plugins()
, introduced by bb83a2f. As noted in the comment inunload_plugins()
in that commit, that function doesn't unload C plugins during shutdown, so the direct call is still required.(Or at least I assume that is what is happening - adding the call back fixes uninit calls for me anyways.)