Skip to content

Conversation

@davidtrevelyan
Copy link

This a just a draft PR to show a possible approach to userspace TLS in RTSan, thereby avoiding recursion from pthread_once implementations calling an intercepted function during __rtsan::Context initialisation.

@davidtrevelyan davidtrevelyan requested a review from cjappl October 30, 2025 16:32
void __rtsan::Context::RealtimePush() { realtime_depth_++; }
void __rtsan::Context::RealtimePush() {
__sanitizer::SpinMutexLock lock{&spin_mutex_};
depths_[pthread_self()].realtime++;
Copy link
Author

@davidtrevelyan davidtrevelyan Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to think about handling the case where depths_ would need to be resized and (potentially) allocate more memory

ExpectBypassed(true);
}

TEST_F(TestRtsanContext, IsProbablyThreadSafe) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I presume this test would almost certainly not be able to be kept. But you never know.

return REAL(os_unfair_lock_lock)(lock);
}

INTERCEPTOR(void, os_unfair_lock_unlock, os_unfair_lock_t lock) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the one that triggered infinite recursion previously

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants