mozilla / cubeb-coreaudio-rs

The audio backend of Firefox on Mac OS X.
ISC License
25 stars 10 forks source link

Replace`*.get_mut()` by `*.store()` on all the `Atomic*` #47

Closed ChunMinChang closed 4 years ago

ChunMinChang commented 4 years ago

Atomic*::get_mut() uses UnsafeCell to mutate the value directly, so Atomic*::get_mut() is only safe if it's called from a single thread. If Atomic*::get_mut() is called from multiple threads, or Atomic* is accessible as mutable references in different threads, it will cause the data race. Thus, for all the Atomic* in the current code, the *.get_mut() should be replaced by *.store() to avoid the data race. This change will solve the data race found by ThreadSanitizer(#34).

ChunMinChang commented 4 years ago

@kinetiknz : Could you review this ?