Page MenuHomePhabricator

[TSan] Avoid triggering assert when program calls OSAtomicCompareAndSwapLong
ClosedPublic

Authored by yln on Jul 12 2021, 2:17 PM.

Details

Summary

A previous change brought the new, relaxed implementation of "on failure
memory ordering" for synchronization primitives in LLVM over to TSan
land [1]. It included the following assert:

// 31.7.2.18: "The failure argument shall not be memory_order_release
// nor memory_order_acq_rel". LLVM (2021-05) fallbacks to Monotonic
// (mo_relaxed) when those are used.
CHECK(IsLoadOrder(fmo));

static bool IsLoadOrder(morder mo) {
  return mo == mo_relaxed || mo == mo_consume
      || mo == mo_acquire || mo == mo_seq_cst;
}

A previous workaround for a false positive when using an old Darwin
synchronization API assumed this failure mode to be unused and passed a
dummy value [2]. We update this value to mo_relaxed which is also the
value used by the actual implementation to avoid triggering the assert.

[1] https://reviews.llvm.org/D99434
[2] https://reviews.llvm.org/D21733

rdar://78122243

Diff Detail

Event Timeline

yln created this revision.Jul 12 2021, 2:17 PM
yln requested review of this revision.Jul 12 2021, 2:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 12 2021, 2:17 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
kubamracek accepted this revision.Jul 12 2021, 11:27 PM
This revision is now accepted and ready to land.Jul 12 2021, 11:27 PM
This revision was landed with ongoing or failed builds.Jul 13 2021, 9:34 AM
This revision was automatically updated to reflect the committed changes.