Bug 1607446 - Fix tsan-detected data race in nsJARChannel; r=valentin,decoder

Simply use Atomic to avoid a data race.

Differential Revision: https://phabricator.services.mozilla.com/D98276
This commit is contained in:
Geoff Brown 2020-12-02 07:36:56 +00:00
parent 084e73855b
commit 58cf701644
3 changed files with 3 additions and 6 deletions

View File

@ -500,7 +500,7 @@ nsresult nsJARChannel::CheckPendingEvents() {
nsresult rv;
auto suspendCount = mPendingEvent.suspendCount;
uint32_t suspendCount = mPendingEvent.suspendCount;
while (suspendCount--) {
if (NS_WARN_IF(NS_FAILED(rv = mPump->Suspend()))) {
return rv;

View File

@ -24,6 +24,7 @@
#include "nsIURI.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "mozilla/Atomics.h"
#include "mozilla/Logging.h"
class nsJARInputThunk;
@ -92,7 +93,7 @@ class nsJARChannel final : public nsIJARChannel,
// |Cancel()|, |Suspend()|, and |Resume()| might be called during AsyncOpen.
struct {
bool isCanceled;
uint32_t suspendCount;
Atomic<uint32_t> suspendCount;
} mPendingEvent;
nsCOMPtr<nsIInputStreamPump> mPump;

View File

@ -239,10 +239,6 @@ extern "C" const char* __tsan_default_suppressions() {
// Bug 1607138
"race:gXPCOMThreadsShutDown\n"
// Bug 1607446
"race:nsJARChannel::Suspend\n"
"race:nsJARChannel::Resume\n"
// Bug 1608462
"deadlock:ScriptPreloader::OffThreadDecodeCallback\n"