Open kiburtse opened 10 months ago
We should probably assert that we're on the main thread when constructing a uv scheduler as this has been a recurring problem.
It also would probably not be too hard to make it partially work on background threads and just not support actually scheduling tasks. The current state of it is just a result of it being written for node before node supported threads.
Expected results
No TSAN warnings at least
Actual Results
tsan warning discovered in #6911 on Realm::get_shared_realm -> Scheduler::make_default -> uv_async_init:
Steps & Code to Reproduce
Consider code like this from test/object-store/realm.cpp:
This will trigger tsan since without set scheduler
get_shared_realm
will construct default scheduler which in case of UV impl is not supposed to be anything other than main thread. It is also problematic when it's shared with at least testing code insideutil::EventLoop
. It's separate instance and handling without integration with themake_default
.Also, according to the doc for libuv
uv_default_loop
is already initialized by first invocation. There is nothing specific what needs to be done about it.Core version
Core version: 13.23.1