WorryFree Computers   »   [go: up one dir, main page]

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

Fix Mutex destructors being incorrectly run at exit (cl/364325997) #345

Merged
merged 4 commits into from
Mar 30, 2021

Conversation

dconeybe
Copy link
Contributor

The code base had several places where global Mutex objects were being allocated statically. As a result, their destructors were being run when exit() was called. This is a violation of the Google C++ style guide, which reads:

Objects with static storage duration are forbidden unless they are trivially destructible.

https://google.github.io/styleguide/cppguide.html#Static_and_Global_Variables

The fix is to simply create these Mutex objects on the heap. By doing so, the destructors will never run.

Mutex objects are not trivially destructible and the execution of their destructors at application exit has no value. Worse, it has been observed that sometimes these destructors fail, resulting in the application failing an assertion check and needlessly crashing. Admittedly, these crashes appeared to be side effects of other use-after-free bugs; however, the crashes were a red herring and hampered investigation of the true bugs.

This sort of has come up before, such as the crashes fixed by firebase/firebase-ios-sdk#6849.

… which can cause crashes when `exit()` is called.

See https://google.github.io/styleguide/cppguide.html#Static_and_Global_Variables
for rationale and firebase/firebase-ios-sdk#6849 for a
similar fix that was made in the iOS client.
@google-cla google-cla bot added the cla: yes label Mar 22, 2021
@dconeybe dconeybe changed the title Port cl/364325997: Fix Mutex destructors being incorrectly run at exit. cl/364325997: Fix Mutex destructors being incorrectly run at exit. Mar 22, 2021
@dconeybe dconeybe changed the title cl/364325997: Fix Mutex destructors being incorrectly run at exit. Fix Mutex destructors being incorrectly run at exit (cl/364325997) Mar 22, 2021
@jonsimantov jonsimantov added the tests-requested: quick Trigger a quick set of integration tests. label Mar 24, 2021
@github-actions github-actions bot added tests: in-progress This PR's integration tests are in progress. and removed tests-requested: quick Trigger a quick set of integration tests. labels Mar 24, 2021
@github-actions
Copy link
github-actions bot commented Mar 24, 2021

❌  Integration test FAILED

Requested by @jonsimantov on commit a4bf4d0
Last updated: Wed Mar 24 17:18:36 PDT 2021
View integration test results

@github-actions github-actions bot added the tests: failed This PR's integration tests failed. label Mar 24, 2021
@jonsimantov jonsimantov removed the tests: failed This PR's integration tests failed. label Mar 24, 2021
@github-actions github-actions bot added the tests: failed This PR's integration tests failed. label Mar 24, 2021
@firebase-workflow-trigger firebase-workflow-trigger bot removed the tests: in-progress This PR's integration tests are in progress. label Mar 25, 2021
jonsimantov
jonsimantov previously approved these changes Mar 29, 2021
@jonsimantov jonsimantov removed the tests: failed This PR's integration tests failed. label Mar 29, 2021
@dconeybe dconeybe assigned dconeybe and unassigned jonsimantov Mar 30, 2021
@dconeybe dconeybe merged commit 3944b11 into main Mar 30, 2021
@dconeybe dconeybe deleted the dconeybe/PortChangelist364325997 branch March 30, 2021 18:34
@firebase firebase locked and limited conversation to collaborators Apr 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants