Skip to content

Make TSAN tests pass with the GIL disabled in free-threaded builds #117657

Closed

Description

@mpage

Feature or enhancement

We need to make the TSAN tests pass with the GIL disabled before we can disable the GIL by default in free-threaded builds.

This should proceed in two phases:

  1. Add suppressions for existing TSAN warnings.
  2. Triage, fix, and remove the suppressions for the warnings enumerated in (1).

How to run the TSAN tests

  1. Build with TSAN:
    env CC=clang CXX=clang++ ./configure --disable-gil --with-thread-sanitizer --with-pydebug && make -j
  2. Run tests:
    env TSAN_OPTIONS=suppressions=<repo_root>/Tools/tsan/suppressions_free_threading.txt ./python -m test --tsan -j4

Working on a race

  1. Verify that the TSAN tests are passing using the steps from above.
  2. Pick a suppression from the section below and assign it to yourself (edit it and add your username next to it). Some of them may be related. If you find that other suppressions are related to the race you're working on please assign them to yourself or contact their owner if they're already assigned.
  3. Delete the suppression from <repo_root>/Tools/tsan/suppressions_free_threading.txt , run the TSAN tests, and verify that the race is reported by TSAN. You may need to comment out unrelated functions (notably, _PyEval_EvalFrameDefault) in order to reproduce the race.
  4. Fix the race.

Suppressions

### Tasks
- [ ] PyInterpreterState_ThreadHead
- [ ] PyThreadState_Clear
- [ ] PyThreadState_Next
- [ ] PyUnstable_InterpreterFrame_GetLine
- [ ] _PyFrame_GetCode
- [ ] _PyFrame_Initialize
- [ ] _PyObject_TryGetInstanceAttribute
- [ ] _Py_slot_tp_getattr_hook
- [x] _multiprocessing_SemLock_acquire_impl
- [x] _multiprocessing_SemLock_release_impl
- [ ] add_threadstate
- [ ] assign_version_tag
- [ ] dump_traceback
- [ ] fatal_error
- [ ] free_threadstate
- [ ] list_get_item_ref
- [x] new_reference
- [ ] pthread_create
- [ ] set_default_allocator_unlocked
- [ ] tstate_delete_common
- [ ] tstate_is_freed
- [ ] type_modified_unlocked
- [ ] write_thread_id

Linked PRs

Activity

  1. added a commit that references this issue on Apr 23, 2024
  2. added 2 commits that reference this issue on Apr 25, 2024
  3. added a commit that references this issue on Apr 25, 2024
  4. added a commit that references this issue on Apr 25, 2024
  5. added 2 commits that reference this issue on Apr 26, 2024
  6. SonicField commented on Apr 30, 2024

    @SonicField
    Contributor

    I will look at initialize_new_array

  7. added 2 commits that reference this issue on Apr 30, 2024
  8. added a commit that references this issue on Apr 30, 2024
  9. added a commit that references this issue on May 1, 2024
  10. added a commit that references this issue on May 2, 2024
  11. added a commit that references this issue on May 2, 2024
  12. added 2 commits that reference this issue on May 3, 2024
  13. added 2 commits that reference this issue on May 6, 2024
  14. added a commit that references this issue on May 7, 2024
  15. added 9 commits that reference this issue on May 8, 2024
  16. added a commit that references this issue on May 8, 2024
  17. added a commit that references this issue on May 8, 2024
  18. added a commit that references this issue on May 8, 2024
  19. added 8 commits that reference this issue on May 9, 2024
  20. added a commit that references this issue on May 9, 2024
  21. added a commit that references this issue on May 9, 2024
  22. added a commit that references this issue on May 9, 2024
  23. SonicField commented on May 9, 2024

    @SonicField
    Contributor

    I'll pick up
    insertdict and lookup_tp_dict now I have initialize_new_array done. I'll bundle all three into a pull request. Sounds reasonable?

  24. colesbury commented on May 9, 2024

    @colesbury
    Contributor

    @SonicField - great! Would you please mark the initialize_new_array as "ready"?

  25. added a commit that references this issue on May 9, 2024
  26. added a commit that references this issue on May 9, 2024
  27. added a commit that references this issue on May 9, 2024
  28. added 3 commits that reference this issue on May 9, 2024
  29. added 3 commits that reference this issue on May 10, 2024
  30. added a commit that references this issue on May 10, 2024
  31. added a commit that references this issue on May 10, 2024
  32. added a commit that references this issue on May 10, 2024
  33. added a commit that references this issue on May 10, 2024
  34. added 3 commits that reference this issue on May 10, 2024
  35. added a commit that references this issue on May 10, 2024
  36. added a commit that references this issue on May 10, 2024
  37. added 2 commits that reference this issue on May 21, 2024
  38. added a commit that references this issue on May 22, 2024
  39. added a commit that references this issue on May 22, 2024
  40. added 4 commits that reference this issue on May 31, 2024
  41. added a commit that references this issue on Jun 1, 2024
  42. added a commit that references this issue on Jun 1, 2024
  43. added a commit that references this issue on Jun 1, 2024
  44. added a commit that references this issue on Jun 1, 2024
  45. added a commit that references this issue on Jun 1, 2024
  46. added 3 commits that reference this issue on Jun 1, 2024
  47. added a commit that references this issue on Jun 1, 2024
  48. added 7 commits that reference this issue on Jun 1, 2024
  49. added a commit that references this issue on Jun 2, 2024
  50. added 3 commits that reference this issue on Jun 2, 2024
  51. added a commit that references this issue on Jun 3, 2024
  52. added a commit that references this issue on Jun 3, 2024
  53. added a commit that references this issue on Jun 3, 2024
  54. added 2 commits that reference this issue on Jun 3, 2024
  55. added a commit that references this issue on Jun 3, 2024
  56. added 7 commits that reference this issue on Jun 3, 2024
  57. added 4 commits that reference this issue on Jun 3, 2024
  58. added a commit that references this issue on Jun 4, 2024
  59. added a commit that references this issue on Jun 4, 2024
  60. added 2 commits that reference this issue on Jun 4, 2024
  61. added 8 commits that reference this issue on Jun 5, 2024
  62. added a commit that references this issue on Jun 6, 2024
  63. added a commit that references this issue on Jun 6, 2024
  64. added 2 commits that reference this issue on Jun 6, 2024
  65. added a commit that references this issue on Jun 12, 2024
  66. added a commit that references this issue on Jun 12, 2024
  67. added 2 commits that reference this issue on Jun 12, 2024
  68. added a commit that references this issue on Jun 13, 2024
  69. added a commit that references this issue on Jun 13, 2024
  70. added 2 commits that reference this issue on Jun 13, 2024
  71. added 3 commits that reference this issue on Jun 13, 2024
  72. added a commit that references this issue on Jun 14, 2024
  73. added 2 commits that reference this issue on Jun 14, 2024
  74. added a commit that references this issue on Jun 15, 2024
  75. added a commit that references this issue on Jun 15, 2024
  76. added 2 commits that reference this issue on Jun 17, 2024
  77. added a commit that references this issue on Jun 17, 2024
  78. added 2 commits that reference this issue on Jun 17, 2024
  79. added a commit that references this issue on Jun 17, 2024
  80. added a commit that references this issue on Jun 17, 2024
  81. added 4 commits that reference this issue on Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions