quickjs-go
quickjs-go copied to clipboard
Returning an empty `ArrayBuffer` crashes
For example:
func myfunc(ctx *quickjs.Context, this quickjs.Value, args []quickjs.Value) quickjs.Value {
return ctx.ArrayBuffer([]byte{})
}
Calling this function Results in:
jsrunner: quickjs.c:1998: JS_FreeRuntime: Assertion `list_empty(&rt->gc_obj_list)' failed.
SIGABRT: abort
Any ideas welcome!
@buke it would be also nice to expose the functions like JS_NewTypedArray, JS_GetTypedArrayBuffer, Value.globalInstanceof (or an alternative)
fixed empty ArrayBuffer crashes & exposed Value.globalInstanceof in https://github.com/buke/quickjs-go/commit/fcd91bd28d7837483c3172a3c7db7bc5ce742d76
quickjs TypedArray api did not have like JS_NewArrayBufferCopy for now , if we implement the Context.TypeArrayBuffer , it will have many unsafe copy operation. I suggest using ArrayBuffer and Eval api to instead , like as :
typeArrayFn, _ := ctx.Eval(`
(data) => {
return new Int32Array(data);
}
`)
binaryData := []uint8{1, 2, 3, 4, 5}
value := ctx.ArrayBuffer(binaryData)
typeArrayFn.Execute(ctx.Null(), value)
pls see TypeArray support at https://github.com/buke/quickjs-go/pull/457
I'm going to close this issue. If there are any problems, please feel free to reopen it.