-
Notifications
You must be signed in to change notification settings - Fork 23
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
Dropping AsyncCore in the logger thread will cause panic #11
Comments
Yeah. Don't do it. 😁 What are you trying to do exactly? :D |
@dpc As shown in the example there is a global logger for code simplicity. There is also panic hook is to capture any uncaught panics into the log file before killing the process. During the time between flushing and log and exiting, there might still be some additional logs coming from other threads. We do not want to lose them, and therefore replaced the global logger with the one that logs to stderr. And that turns out to cause EDEADLK when the panicking thread is the logger thread 🙃. I'm checking if this issue is the expected behavior before changing the drainer implementation. |
Global logger behind a mutex? Oh dear. Well, dropping |
I can't think of any good excuse not to include such "fix". Can you fill a PR? In the meantime I'll think about it a little. |
AsyncCore::drop
(andAsyncGuard::drop
) needs tojoin
the logger thread. Whenjoin
is called inside the logger thread itself, it will unconditionally panic.The
Drain::log()
function is executed in the logger thread. Therefore, if we drop theAsyncCore
insidelog()
, or iflog()
panics and we have a custom panic hook and we drop theAsyncCore
in the hook, it will cause the EDEADLK crash.Demo:
The marked line will panic on Linux and macOS.
The text was updated successfully, but these errors were encountered: