aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-07-04 04:07:35 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-07-04 04:07:35 -0700
commitbb96aa5156cd13cb6662991368a10b19a8d13239 (patch)
tree340c71598115311b5acba302b9931db1c8e4536a
parentf49a308d2c2d30c798de738e05b528ecc4eaf9ee (diff)
downloadbun-bb96aa5156cd13cb6662991368a10b19a8d13239.tar.gz
bun-bb96aa5156cd13cb6662991368a10b19a8d13239.tar.zst
bun-bb96aa5156cd13cb6662991368a10b19a8d13239.zip
Fix crash
-rw-r--r--src/bun.js/bindings/ZigGlobalObject.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp
index b3236a4a2..4bb5445e1 100644
--- a/src/bun.js/bindings/ZigGlobalObject.cpp
+++ b/src/bun.js/bindings/ZigGlobalObject.cpp
@@ -1026,11 +1026,12 @@ using MicrotaskCallback = void (*)(void*);
JSC_DEFINE_HOST_FUNCTION(functionNativeMicrotaskTrampoline,
(JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
{
- JSCell* cellPtr = callFrame->uncheckedArgument(0).asCell();
- JSCell* callbackPtr = callFrame->uncheckedArgument(1).asCell();
+ // Do not use JSCell* here because the GC will try to visit it.
+ double cellPtr = callFrame->uncheckedArgument(0).asNumber();
+ double callbackPtr = callFrame->uncheckedArgument(1).asNumber();
- void* cell = reinterpret_cast<void*>(cellPtr);
- auto* callback = reinterpret_cast<MicrotaskCallback>(callbackPtr);
+ void* cell = reinterpret_cast<void*>(bitwise_cast<uintptr_t>(cellPtr));
+ auto* callback = reinterpret_cast<MicrotaskCallback>(bitwise_cast<uintptr_t>(callbackPtr));
callback(cell);
return JSValue::encode(jsUndefined());
}
@@ -4410,7 +4411,9 @@ extern "C" void JSC__JSGlobalObject__reload(JSC__JSGlobalObject* arg0)
extern "C" void JSC__JSGlobalObject__queueMicrotaskCallback(Zig::GlobalObject* globalObject, void* ptr, MicrotaskCallback callback)
{
JSFunction* function = globalObject->nativeMicrotaskTrampoline();
- globalObject->queueMicrotask(function, JSValue(reinterpret_cast<JSC::JSCell*>(ptr)), JSValue(reinterpret_cast<JSC::JSCell*>(callback)), jsUndefined(), jsUndefined());
+
+ // Do not use JSCell* here because the GC will try to visit it.
+ globalObject->queueMicrotask(function, JSValue(bitwise_cast<double>(reinterpret_cast<uintptr_t>(ptr))), JSValue(bitwise_cast<double>(reinterpret_cast<uintptr_t>(callback))), jsUndefined(), jsUndefined());
}
JSC::Identifier GlobalObject::moduleLoaderResolve(JSGlobalObject* globalObject,