-
Type: Task
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: JavaScript
-
Fully Compatible
-
Query 2020-08-24
-
31
Problem
When the server is built with the ThreadSanitizer instrumentation (TSAN) (build variant: “~ TSAN Enterprise Ubuntu 20.04 DEBUG (Biggie)”) execution of JavaScript functions fails with the exception below.
{"code":139,"codeName":"JSInterpreterFailure","errmsg":"InternalError: too much recursion"}
An example of the test that fails under TSAN is jstests/core/mr_sort.js.
The stack size for MozJS JavaScript engine execution is decided at https://github.com/mongodb/mongo/blob/master/src/mongo/scripting/mozjs/implscope.cpp#L378. For TSAN builds the stack size in a relevant test is around 180000 bytes, and for a regular build - around 950000 bytes, due to a memory overhead of TSAN instrumentation. 200kB of free stack space appears to be not enough to run JavaScript functions.
Potential solutions
- Increase stack sizes for ThreadSanitizer instrumented builds.
- On client connected worker threads, one could add TSAN specific customization to launchServiceWorkerThread to increase the stack sizes when using TSAN. If it is on the thread owned by the ProxyScope it will be harder because it uses a std::thread, and we don’t have control over the stack sizes for those.