Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Unified Diff: util/misc/initialization_state.h

Issue 538233002: Fix problems discovered with gcc 4.9.1 (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Also fix InitializationState Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « util/mac/process_reader_test.cc ('k') | util/misc/initialization_state_dcheck.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/misc/initialization_state.h
diff --git a/util/misc/initialization_state.h b/util/misc/initialization_state.h
index b5a72031698e2b82048e300899877cfbc44b817c..b0496e5c131909733aa26ba9843d3a0feed5149c 100644
--- a/util/misc/initialization_state.h
+++ b/util/misc/initialization_state.h
@@ -86,7 +86,11 @@ class InitializationState {
void set_state(State state) { state_ = state; }
private:
- State state_;
+ // state_ is volatile to ensure that it’ll be set by the destructor when it
+ // runs. Otherwise, optimizations might prevent it from ever being set to
+ // kStateDestroyed, limiting this class’ ability to catch use-after-free
+ // errors.
+ volatile State state_;
DISALLOW_COPY_AND_ASSIGN(InitializationState);
};
« no previous file with comments | « util/mac/process_reader_test.cc ('k') | util/misc/initialization_state_dcheck.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698