-
Notifications
You must be signed in to change notification settings - Fork 481
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
Suspend core by default when calling plugin command functions #5112
Conversation
ed9ca68
to
f888230
Compare
so no conflicts can happen when changing global state inside the Textures module
f888230
to
d08863a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as per comments
i am especially not comfortable with adding a core suspender to viewscreen render or logic methods
fixed
what about overlay.cpp, where we call into Lua from render, logic, and feed? |
Might be needed there, since that's going to be using the Lua state in Core, which is shared across threads and needs to be arbitrated somehow. I don't know if the lock in the update: I looked at the code used in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having looked over the CoreSuspender semantics I think this is probably OK.
We do need to ensure that access to the global Lua state is properly arbitrated, but this isn't the PR to do that.
I agree suspending in a vmethod seems very unsafe to me. Did we remove CoreSuspendClaimer? I'm guessing from context that it was intended to be used as a stand-in for CoreSuspender on the render thread to prevent deadlocks. It's possible other things have changed since I Iast looked at this code that make this safer now. |
Sorry I missed a mistake on review. There's a |
@@ -2416,7 +2416,7 @@ int Core::Shutdown ( void ) | |||
d->hotkeythread.join(); | |||
d->iothread.join(); | |||
|
|||
CoreSuspendClaimer suspend; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be here at all. This is in Core::Shutdown
, the core suspension mechanism has already been dismantled at this point and all DFHack threads, as well as the DF simulation thread, have been terminated. The suspender should be removed entirely since there's nothing to protect against here.
This usage came up when I added instrumentation to detect attempts to acquire a CoreSuspender
from the DF render thread, because doing this is unsafe. It happens that DF calls dfhooks_shutdown
from the render (main) thread, so the attempt to acquire a CoreSuspender
here set off the instrumentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in ebac377
CoreSuspendClaimer has been an alias for CoreSuspender since #1304 (merged in 2018). I just removed the alias to make the now-uniform semantics clearer. |
it was aliased to |
Fixes: #5102
Should be tested with #5075