-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Loggers run beyond the usable lifetime of CRT #2409
Comments
This comment was marked as outdated.
This comment was marked as outdated.
Thanks for making a PR to fix this. Reviewing the PR |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
I canceled the PR, it was insufficient, but the issue stands. Using |
Here's the fix we're using in production for this issue, in case it's helpful to anyone.
|
The fix for shutting down logging before CRT should have been sufficient, however I think there are other lifetime issues at play here that need to be tracked down. |
#2480 resolved this issue effectively. |
|
Describe the bug
#1996 a change was made to shutdown the CRT before shutting down both loggers. In general, the shutdown sequence should always be the exact reverse of the init sequence to avoid lifetime issues, otherwise there is an architectural issue to solve. If the CRT logs during shutdown, it needs to be smart enough not to fall over if there is no logger. I believe the fix for the issue observed was performed at the wrong code layer.
If one is using CUSTOM_MEMORY_MANAGEMENT, when the CRT is shutdown, the custom memory allocator is invalidated. At that time, the logging thread is still active and may call for an allocation.
The following assertion from aws-c-common demonstrates this behavior. Placed log message wrappers around the shutdown calls. There is no message indicating logging was shut down. "Shutting Down" is logged immediately before we call ShutdownAPI. The fix is to restore the original ordering.
Expected Behavior
The CRT logger's lifetime cannot exceed the CRT's lifetime.
No assertion.
Current Behavior
The logger thread is running beyond the CRT lifetime and causing an error.
Reproduction Steps
Difficult to reproduce, timing related.
Possible Solution
Revert the change.
Additional Information/Context
Should provide a unit test that does init/shutdown many times in a row, in the same executable, to prove the behavior is correct.
AWS CPP SDK version used
1.11.47
Compiler and Version used
9.5.0
Operating System and version
Linux (AL2)
The text was updated successfully, but these errors were encountered: