# Data race in triangle example

**URL:** <https://discourse.glfw.org/t/data-race-in-triangle-example/2990>\
**Category:** support\
**Created:** [January 30, 2026, 3:43pm UTC](https://discourse.glfw.org/t/data-race-in-triangle-example/2990 "2026-01-30T15:43:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![robin162](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/robin162/32/1068_2.png) [@robin162](https://discourse.glfw.org/u/robin162)\
**Post date:** [January 30, 2026, 3:43pm UTC](https://discourse.glfw.org/t/data-race-in-triangle-example/2990/1 "2026-01-30T15:43:20Z")

</div>

I’m trying to recreate a data race in our production environment. So, I’m running the `triangle-opengl` example (`GLFW` version 3.4), with `-fsanitize=thread` and lo and behold:

```auto
$ ./examples/triangle-opengl
==================
WARNING: ThreadSanitizer: data race (pid=103603)
  Write of size 8 at 0x722c00005800 by main thread:
    #0 free ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:724 (libtsan.so.2+0x57c71) (BuildId: 38097064631f7912bd33117a9c83d08b42e15571)
    #1 <null> <null> (libgallium-25.0.7-0ubuntu0.24.04.2.so+0x554162) (BuildId: e4db5a0049ad7c33fdf8fbe94ff4971d4264e05c)
    #2 <null> <null> (libgallium-25.0.7-0ubuntu0.24.04.2.so+0xde6599) (BuildId: e4db5a0049ad7c33fdf8fbe94ff4971d4264e05c)
    #3 _glfwCreateWindowX11 /home/robin/Sandbox/glfw/src/x11_window.c:2007 (triangle-opengl+0x46a7d) (BuildId: 1a8e8bce19eba49572394b6a50f78094b37997f6)
    #4 glfwCreateWindow /home/robin/Sandbox/glfw/src/window.c:246 (triangle-opengl+0x27e37) (BuildId: 1a8e8bce19eba49572394b6a50f78094b37997f6)
    #5 main /home/robin/Sandbox/glfw/examples/triangle-opengl.c:94 (triangle-opengl+0x17962) (BuildId: 1a8e8bce19eba49572394b6a50f78094b37997f6)

  Previous write of size 8 at 0x722c00005800 by thread T1:
    #0 malloc ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:665 (libtsan.so.2+0x54b3f) (BuildId: 38097064631f7912bd33117a9c83d08b42e15571)
    #1 <null> <null> (libgallium-25.0.7-0ubuntu0.24.04.2.so+0x558f9c) (BuildId: e4db5a0049ad7c33fdf8fbe94ff4971d4264e05c)
    #2 <null> <null> (libgallium-25.0.7-0ubuntu0.24.04.2.so+0x56087f) (BuildId: e4db5a0049ad7c33fdf8fbe94ff4971d4264e05c)

  Thread T1 'triangl:disk$0' (tid=103605, running) created by main thread at:
    #0 pthread_create ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:1022 (libtsan.so.2+0x5ac1a) (BuildId: 38097064631f7912bd33117a9c83d08b42e15571)
    #1 <null> <null> (libgallium-25.0.7-0ubuntu0.24.04.2.so+0x5936f4) (BuildId: e4db5a0049ad7c33fdf8fbe94ff4971d4264e05c)
    #2 _glfwInitGLX /home/robin/Sandbox/glfw/src/glx_context.c:366 (triangle-opengl+0x4eda0) (BuildId: 1a8e8bce19eba49572394b6a50f78094b37997f6)
    #3 _glfwCreateWindowX11 /home/robin/Sandbox/glfw/src/x11_window.c:1975 (triangle-opengl+0x467fe) (BuildId: 1a8e8bce19eba49572394b6a50f78094b37997f6)
    #4 glfwCreateWindow /home/robin/Sandbox/glfw/src/window.c:246 (triangle-opengl+0x27e37) (BuildId: 1a8e8bce19eba49572394b6a50f78094b37997f6)
    #5 main /home/robin/Sandbox/glfw/examples/triangle-opengl.c:94 (triangle-opengl+0x17962) (BuildId: 1a8e8bce19eba49572394b6a50f78094b37997f6)

SUMMARY: ThreadSanitizer: data race (/lib/x86_64-linux-gnu/libgallium-25.0.7-0ubuntu0.24.04.2.so+0x554162) (BuildId: e4db5a0049ad7c33fdf8fbe94ff4971d4264e05c) 
==================
ThreadSanitizer: reported 1 warnings

```

Is this a ‘false positive’ in the sanitizer? Is this caused because of the way my system is set up (I’m on Ubuntu 24.04 btw)? Should I be worried?

Also, I read the documentation and realized this `disk$0` thread has to do with on-disk cache. Consequently, I tried with `export MESA_SHADER_CACHE_DISABLE=true` , but this just results in even more data races.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [January 30, 2026, 4:24pm UTC](https://discourse.glfw.org/t/data-race-in-triangle-example/2990/2 "2026-01-30T16:24:16Z")

</div>

This isn’t in GLFW itself, as it does no threading. The sanitizer output thinks this is in your `libgallium` library. I would suspect a false positive unless you are using a pre-release build of this library, but I can’t say for sure and I don’t know enough about libgallium to be of further help.

---

<div class="post-metadata">

**Author:** ![robin162](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/robin162/32/1068_2.png) [@robin162](https://discourse.glfw.org/u/robin162)\
**Post date:** [February 2, 2026, 1:58pm UTC](https://discourse.glfw.org/t/data-race-in-triangle-example/2990/3 "2026-02-02T13:58:36Z")

</div>

Thank you for your answer! I directed this issue at the mesa folks instead: [Making sure you're not a bot!](https://gitlab.freedesktop.org/mesa/mesa/-/issues/14784)

EDIT: don’t know what this ‘Making sure you’re not a bot!’ text is, but it’s just a link to the mesa issue
