Skip to content
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

more process event thread safety hardening - rework logging #35

Merged
merged 6 commits into from
Jun 30, 2024

Conversation

apple1417
Copy link
Contributor

No description provided.

… logging module

pending changes in next commit
Because `uconsole_output_text` may be implemented in terms of an unreal function call, if process event is locking it may deadlock.
This happens if external code attempts to acquire a lock during a hook, while at the same time trying to print a log message on the thread which holds that lock.

While it's really the external code's responsibility to avoid this, the fact that every single log message can cause it is absolutely awful, it transitively affects half the codebase in non-obvious ways.
By moving printing to it's own worker thread, we can be sure that thread will never be holding a conflicting lock.
As a bonus, this means we move the filesystem access to the worker thread too - though we still do string formatting and copying on the logic threads.

If someone hooks output text for some reason, while it will trigger hooks on the worker thread when we print, that thread will always already hold the process event lock, so it won't be able to deadlock.
unrelated to previous commits, but been bothering me for a bit
@apple1417 apple1417 merged commit df07e79 into bl-sdk:master Jun 30, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant