# How to track down multi-threading issues?

**URL:** <https://discourse.julialang.org/t/how-to-track-down-multi-threading-issues/81248>\
**Category:** New to Julia\
**Tags:** multithreading\
**Created:** [May 18, 2022, 9:38am UTC](https://discourse.julialang.org/t/how-to-track-down-multi-threading-issues/81248 "2022-05-18T09:38:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChrisJefferson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisjefferson/32/18576_2.png) [@ChrisJefferson](https://discourse.julialang.org/u/ChrisJefferson)\
**Post date:** [May 18, 2022, 9:38am UTC](https://discourse.julialang.org/t/how-to-track-down-multi-threading-issues/81248/1 "2022-05-18T09:38:04Z")

</div>

I have some multithreaded code which is crashing Julia – I suspect the problem is changing the same variable in multiple threads without appropriate locks.

Are there any tools which can help me track down the problem? For example, in C++ I’d try clang’s “thread sanitiser”, or “DRD” from valgrind, which could help me see which variables are being unsafely accessed.

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [May 18, 2022, 12:15pm UTC](https://discourse.julialang.org/t/how-to-track-down-multi-threading-issues/81248/2 "2022-05-18T12:15:16Z")

</div>

Julia can run under valgrind as well:

[https://docs.julialang.org/en/v1/devdocs/valgrind/](https://docs.julialang.org/en/v1/devdocs/valgrind/)

I haven’t tried it myself though. I’m not aware of any julia specific tools though. Maybe @tkf knows some more?

---

<div class="post-metadata">

**Author:** ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)\
**Post date:** [May 18, 2022, 3:44pm UTC](https://discourse.julialang.org/t/how-to-track-down-multi-threading-issues/81248/3 "2022-05-18T15:44:18Z")

</div>

The single-source-of-truth for the TSAN support is the CI setup for TSAN test:

- CI setup: [julia-buildkite/tsan.yml at main · JuliaCI/julia-buildkite · GitHub](https://github.com/JuliaCI/julia-buildkite/blob/main/pipelines/main/misc/sanitizers/tsan.yml)
- TSAN build script: [julia/build.sh at master · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/blob/master/contrib/tsan/build.sh)

I think the latest discussion was: [https://github.com/JuliaLang/julia/pull/42444](https://github.com/JuliaLang/julia/pull/42444) There are still some issues and we can’t build “full” `julia` for using TSAN yet.

I’ve never really used valgrind. I don’t know other tools specific to multi-threading. I use non-specific tools like rr sometimes but I don’t recall anything that could be useful for the situation in the OP.
