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.26k stars 1.58k forks source link

TSAN: reconcile report_thread_leaks with dart:io's exit #41811

Open rmacnak-google opened 4 years ago

rmacnak-google commented 4 years ago

dart:io's exit call's libc's exit without first calling Dart_Cleanup. This can cause TSAN to complain about leaks of VM thread pool threads. Ideally we would inform TSAN that when we exit this way we don't care about leaks (and likewise for LSAN), but there doesn't appear to be a way to set TSAN's report_thread_leaks at runtime. We don't want completely ignore thread leak reportings because it is useful when we shutdown gracefully (main isolate completes its message and has no open receive ports).

mkustermann commented 4 years ago

The puzzling thing is that global C++ state should be treated as strong roots by the leak sanitizer and therefore everything (transitively) reachable from it should not be considered as leaks. See lsan design doc

So I would assume the global thread pool, various global mutexes/monitors and global lists are treated as roots. One of those roots is a global list of isolate groups, each of which has a list of isolates. So all those resources should not be considered as leaks.

rmacnak-google commented 4 years ago

Thanks for the pointer, I had misunderstood LSAN as wanting everything to have been freed before exit.