dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.11k stars 1.56k forks source link

[vm][tsan] race on field table #47122

Open askeksa-google opened 3 years ago

askeksa-google commented 3 years ago

There are new test failures on [vm/ffi] Adds param number in trampoline null error.

The tests

vm/cc/Profiler_ToggleRecordAllocation Crash (expected Pass)

are failing on configurations

dartk-tsan-linux-release-x64
dcharkes commented 3 years ago

Log https://dart-ci.appspot.com/log/vm-kernel-tsan-linux-release-x64/dartk-tsan-linux-release-x64/1756/vm/cc/Profiler_ToggleRecordAllocation

dcharkes commented 3 years ago

This reproduces on the commit before mine as well: 01c4999b318e3a6f1475510d577d473377434340. However, it was green on that commit on the CI. Also reproduces locally on older commits: 8c9a4690844bfd574d1b778e5a324a96512439bf.

Write:

WARNING: ThreadSanitizer: data race (pid=1497484)
  Write of size 8 at 0x7b1000002118 by thread T2:
    #0 operator delete(void*) ../staging/llvm_build/tools/clang/stage2-bins/runtimes/runtimes-x86_64-unknown-linux-gnu-bins/compiler-rt/lib/tsan/rtl/tsan_new_delete.cpp:126 (run_vm_tests+0x3df7aee)
    #1 dart::Isolate::set_field_table(dart::Thread*, dart::FieldTable*) ../../out/ReleaseTSANX64/../../runtime/vm/isolate.h:979 (run_vm_tests+0x430f682)

https://github.com/dart-lang/sdk/blob/bc1c71fd9b25f9d0bcb281035ef1cf4ec17e8ed6/runtime/vm/isolate.h#L977-L982

Read:

  Previous read of size 8 at 0x7b1000002118 by thread T4 (mutexes: write M2387142823118432, write M5764859723528416):
    #0 dart::FieldTable::table() ../../out/ReleaseTSANX64/../../runtime/vm/field_table.h:42 (run_vm_tests+0x437f7e1)

https://github.com/dart-lang/sdk/blob/bc1c71fd9b25f9d0bcb281035ef1cf4ec17e8ed6/runtime/vm/field_table.h#L42

Relevant commits e2aadc7a075da3b52957c93dc39d3b7fc86a5d1b, 9c4a322b086dc229c5eafc1fbeaf9d33ce9f4c86. Because the issue reproduces on older commits locally, it is unclear how long this has been happening. But it could not have been before 9c4a322b086dc229c5eafc1fbeaf9d33ce9f4c86 at least.

cc @aam.