This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int32_t oldVals = myVal.bitfields; // load all bitfields | |
int32_t newVals = oldVals | 1 << fieldOffset; // modify just one | |
myVal.bitfields = newVals; // write all bitfields |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static bool sInitialized = false; | |
static Mutex sMutex; // guards sInitialized | |
// racily check if initialized (gotta go fast!) | |
if (!sInitialized) { | |
// now properly check | |
auto lock = sMutex.Lock(); | |
if (!sInitialized) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WARNING: ThreadSanitizer: data race (pid=1544) | |
Write of size 8 at 0x7b30000048d8 by thread T21: | |
#0 __xstat64 compiler-rt/lib/tsan/../sanitizer_common/sanitizer_common_interceptors.inc:6607:3 | |
#1 stat64 /usr/include/x86_64-linux-gnu/sys/stat.h:504:10 | |
#2 FillStatCache xpcom/io/nsLocalFileUnix.cpp:304:7 | |
#3 nsLocalFile::GetPermissions(unsigned int*) xpcom/io/nsLocalFileUnix.cpp:1254:3 | |
#4 nsAtomicFileOutputStream::DoOpen() netwerk/base/nsFileStreams.cpp:804:9 | |
[...] | |
#10 mozilla::PreferencesWriter::Write([...]) modules/libpref/Preferences.cpp:2907:10 | |
[...] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WARNING: ThreadSanitizer: data race (pid=1121) | |
Read of size 2 at 0x7b74001a6fdc by main thread (mutexes: write M899729694995224136, write M119199653296761384): | |
#0 mozilla::layers::AsyncPanZoomController::ApplyAsyncTestAttributes() gfx/layers/apz/src/AsyncPanZoomController.cpp:4218:7 | |
#1 AutoApplyAsyncTestAttributes gfx/layers/apz/src/AsyncPanZoomController.cpp:596:10 | |
[...] | |
#34 main browser/app/nsBrowserApp.cpp:308:16 | |
Previous write of size 2 at 0x7b74001a6fdc by thread T29: | |
#0 MarkAsyncTransformAppliedToContent gfx/layers/apz/src/AsyncPanZoomController.h:1605:37 | |
#1 mozilla::layers::APZSampler::MarkAsyncTransformAppliedToContent([...]) gfx/layers/apz/src/APZSampler.cpp:192:21 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <thread> | |
int x = 0; | |
void print_x() { | |
std::cerr << "x is " << x << std::endl; | |
} | |
void set_x(int new_x) { |