-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[Apple][RTSan] Realtime sanitizers are failing in Apple CI #124873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1037,18 +1037,18 @@ TEST(TestRtsanInterceptors, PthreadJoinDiesWhenRealtime) { | |
|
|
||
| #if SANITIZER_APPLE | ||
|
|
||
| #pragma clang diagnostic push | ||
| // OSSpinLockLock is deprecated, but still in use in libc++ | ||
| #pragma clang diagnostic ignored "-Wdeprecated-declarations" | ||
| TEST(TestRtsanInterceptors, OsSpinLockLockDiesWhenRealtime) { | ||
| auto Func = []() { | ||
| OSSpinLock spin_lock{}; | ||
| OSSpinLockLock(&spin_lock); | ||
| }; | ||
| ExpectRealtimeDeath(Func, "OSSpinLockLock"); | ||
| ExpectNonRealtimeSurvival(Func); | ||
| } | ||
| #pragma clang diagnostic pop | ||
| // #pragma clang diagnostic push | ||
| // // OSSpinLockLock is deprecated, but still in use in libc++ | ||
| // #pragma clang diagnostic ignored "-Wdeprecated-declarations" | ||
| // TEST(TestRtsanInterceptors, OsSpinLockLockDiesWhenRealtime) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For this test, is it possible that your internal build of MacOS completely killed off OsSpinLock, and this call no longer does anything? That's my very naive hunch seeing as it's wrapped in in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I think I have an explanation for this one. The locks were changed to macros that point to other locking mechanisms |
||
| // auto Func = []() { | ||
| // OSSpinLock spin_lock{}; | ||
| // OSSpinLockLock(&spin_lock); | ||
| // }; | ||
| // ExpectRealtimeDeath(Func, "OSSpinLockLock"); | ||
| // ExpectNonRealtimeSurvival(Func); | ||
| // } | ||
| // #pragma clang diagnostic pop | ||
|
|
||
| TEST(TestRtsanInterceptors, OsUnfairLockLockDiesWhenRealtime) { | ||
| auto Func = []() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To explain what is going on here (just being explicit so you have as much info as possible, you may know any/all of this).
Small types which are made atomics don't need locks, they rely on arch specific instructions. Luckily for us real-time programmers, C++ standard added the
.is_lock_freeassertion so we could sanity check ourselves before using these in timing critical code.The first half of these test determines that a basic float may be used atomically without an underlying lock happening, we don't intercept anything and don't die.
The second half test uses a mega 2048 float buffer, which cannot be atomically updated without a lock (on any arch I know of). We then test that we intercept the lock call that happens implicitly under the hood. On my mac this intercepts a pthread_mutex_lock I believe.
This passes on my mac, at least, but perhaps Apple changed the internal implementation of the STL to use a different type of lock we don't currently intercept? That fix would be easy enough to do, we could just add the new call into our interceptors.
If you have found some way to make an atomic update of 2048 floats at once with NO LOCKS, please share the secret sauce 👀