From 03a2b34c191146fa09c014a20e2dfd59e0a68431 Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Thu, 26 Feb 2026 19:18:28 +0900 Subject: [PATCH] fix: use WriteBarrierEarlyInit for WriteBarriers initialized before finishCreation NodeVMModule::m_moduleWrapper and NodeVMSyntheticModule::m_syntheticEvaluationSteps were using the regular WriteBarrier constructor (vm, this, value) in their member initializer lists, which calls vm.writeBarrier(this, ...) before the cell is markable (finishCreation has not been called yet). Use WriteBarrierEarlyInit instead, consistent with the adjacent m_context field and other similar patterns in the codebase. --- src/bun.js/bindings/NodeVMModule.cpp | 2 +- src/bun.js/bindings/NodeVMSyntheticModule.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bun.js/bindings/NodeVMModule.cpp b/src/bun.js/bindings/NodeVMModule.cpp index ffa755f5c6..04d0e3d19a 100644 --- a/src/bun.js/bindings/NodeVMModule.cpp +++ b/src/bun.js/bindings/NodeVMModule.cpp @@ -154,7 +154,7 @@ NodeVMModule::NodeVMModule(JSC::VM& vm, JSC::Structure* structure, WTF::String i : Base(vm, structure) , m_identifier(WTF::move(identifier)) , m_context(context && context.isObject() ? asObject(context) : nullptr, JSC::WriteBarrierEarlyInit) - , m_moduleWrapper(vm, this, moduleWrapper) + , m_moduleWrapper(moduleWrapper, JSC::WriteBarrierEarlyInit) { } diff --git a/src/bun.js/bindings/NodeVMSyntheticModule.h b/src/bun.js/bindings/NodeVMSyntheticModule.h index e269bd94dc..40986e8d02 100644 --- a/src/bun.js/bindings/NodeVMSyntheticModule.h +++ b/src/bun.js/bindings/NodeVMSyntheticModule.h @@ -54,7 +54,7 @@ private: NodeVMSyntheticModule(JSC::VM& vm, JSC::Structure* structure, WTF::String identifier, JSValue context, JSValue moduleWrapper, WTF::HashSet exportNames, JSValue syntheticEvaluationSteps) : Base(vm, structure, WTF::move(identifier), context, moduleWrapper) , m_exportNames(WTF::move(exportNames)) - , m_syntheticEvaluationSteps(vm, this, syntheticEvaluationSteps) + , m_syntheticEvaluationSteps(syntheticEvaluationSteps, JSC::WriteBarrierEarlyInit) { }