Skip to content

Commit b4abd4b

Browse files
fhanaujasnell
authored andcommitted
Fix minor undefined behavior in modules-new-test
When running under high load, a race condition in modules-new-test.c++ could lead to the V8 isolate being destroyed too late, leading to a member access within null pointer during isolate deallocation.
1 parent ba8f5de commit b4abd4b

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/workerd/jsg/modules-new-test.c++

+11-9
Original file line numberDiff line numberDiff line change
@@ -1600,15 +1600,17 @@ KJ_TEST("Using a registry from multiple threads works") {
16001600
static constexpr auto makeThread = [](ModuleRegistry& registry) {
16011601
auto paf = kj::newPromiseAndCrossThreadFulfiller<void>();
16021602
kj::Thread thread([&registry, fulfiller = kj::mv(paf.fulfiller)] {
1603-
PREAMBLE([&](Lock& js) {
1604-
CompilationObserver compilationObserver;
1605-
auto attached = registry.attachToIsolate(js, compilationObserver);
1606-
js.tryCatch([&] {
1607-
auto val = ModuleRegistry::resolve(js, "file:///foo");
1608-
KJ_ASSERT(val.isNumber());
1609-
}, [&](Value exception) { js.throwException(kj::mv(exception)); });
1610-
fulfiller->fulfill();
1611-
});
1603+
{
1604+
PREAMBLE([&](Lock& js) {
1605+
CompilationObserver compilationObserver;
1606+
auto attached = registry.attachToIsolate(js, compilationObserver);
1607+
js.tryCatch([&] {
1608+
auto val = ModuleRegistry::resolve(js, "file:///foo");
1609+
KJ_ASSERT(val.isNumber());
1610+
}, [&](Value exception) { js.throwException(kj::mv(exception)); });
1611+
});
1612+
}
1613+
fulfiller->fulfill();
16121614
});
16131615
thread.detach();
16141616
return kj::mv(paf.promise);

0 commit comments

Comments
 (0)