Skip to content

Conversation

xal-0
Copy link
Member

@xal-0 xal-0 commented Jul 18, 2025

Lets us detect lock order inversions on jl_mutex_ts, races on mutex initialization, and shows the list of locked mutexes when some other ThreadSanitizer warning is shown.

@xal-0 xal-0 added the multithreading Base.Threads and related functionality label Jul 18, 2025
@vchuravy
Copy link
Member

Very cool! Would it make sense to also push this into user code, so that the locks written in Julia code support this?

@xal-0
Copy link
Member Author

xal-0 commented Jul 18, 2025

That's the plan, though it will require some codegen hacks to make everything bootstrap fast enough. If the decision to include the call to the hooks is made in Julia, we won't easily be able to cross compile the sysimage from a non-tsan version of Julia.

@vchuravy
Copy link
Member

Can we put it in build_h.jl(

@printf "%s\n" "const BUILD_TRIPLET = \"$(BB_TRIPLET_LIBGFORTRAN_CXXABI)\"" >> $@
)? Or is the cross-compile going to use the one from the "host"?

@xal-0
Copy link
Member Author

xal-0 commented Jul 30, 2025

I'm not sure how it should work. So far I've been cross-compiling from a non-tsan sysimage and I'd like to keep that option available if possible. The closest thing we have to codegen-conditional features right now is Expr(:boundscheck), and I suppose a generic version could be useful for the other sanitizers.

@vtjnash
Copy link
Member

vtjnash commented Aug 1, 2025

Commonly we have ccalls that get optimized in ccall.cpp to do something efficient or removed

@xal-0 xal-0 merged commit f5b97a8 into JuliaLang:master Aug 1, 2025
6 of 9 checks passed
@xal-0 xal-0 deleted the tsan-jl-mutex branch August 1, 2025 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
multithreading Base.Threads and related functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants