Skip to content

Update quickjs-ng to 2c620e4 and fix ArrayBuffer for new JS_NewArrayBuffer signature - #723

Open
richarddd wants to merge 7 commits into
DelSkayn:masterfrom
richarddd:sync/quickjs-ng-bump
Open

Update quickjs-ng to 2c620e4 and fix ArrayBuffer for new JS_NewArrayBuffer signature#723
richarddd wants to merge 7 commits into
DelSkayn:masterfrom
richarddd:sync/quickjs-ng-bump

Conversation

@richarddd

@richarddd richarddd commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

quickjs-ng added a max_len param to JS_NewArrayBuffer and changed the free callback into a realloc callback, and moved ref_count out of the object body into the allocator header.

Updated both call sites and the callback signatures, regenerated bindings, and dropped the ref_count check in drop_context since that field is no longer readable.

Updated to quickjs-ng 0.16.2 (2c620e4), which includes several bug fixes on top of 0.16.0 with no further API changes.

Supersedes #722.

@richarddd
richarddd force-pushed the sync/quickjs-ng-bump branch 3 times, most recently from 21039a0 to f0ffaf5 Compare August 9, 2026 04:18
@richarddd
richarddd force-pushed the sync/quickjs-ng-bump branch from f0ffaf5 to 36033d3 Compare August 24, 2026 19:37
@richarddd richarddd changed the title Update quickjs-ng to 10b9969 and fix ArrayBuffer for new JS_NewArrayBuffer signature Update quickjs-ng to 2c620e4 and fix ArrayBuffer for new JS_NewArrayBuffer signature Aug 24, 2026

@Sytten Sytten left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of comments

Comment thread core/src/context/async.rs
Comment on lines -88 to -97
let p =
unsafe { &mut *(ctx.as_ptr() as *mut crate::context::ctx::RefCountHeader) };
if p.ref_count <= 1 {
// Lock was poisoned, this should only happen on a panic.
// We should still free the context.
// TODO see if there is a way to recover from a panic which could cause the
// following assertion to trigger
#[cfg(feature = "std")]
assert!(std::thread::panicking());
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there a way to detect lock poisoning or do panic recovery?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we abandon the idea of supporting bellard quickjs?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/richarddd/rquickjs/pull/3/changes

I dont know it seems quite risky as the ABI has diverted quite a bit, not to bad tho.

Comment thread core/src/value/array_buffer.rs Outdated
Comment on lines +213 to +215
if size != 0 {
return core::ptr::null_mut();
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment to indicate that we only need to support the size 0 case (free command) and that other sizes are not expected since we set max_len to 0 (fixed) in the New function.

Comment thread core/src/value/array_buffer.rs Outdated
ptr: *mut c_void,
size: qjs::size_t,
) -> *mut c_void {
if size != 0 {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment

Comment thread core/src/value/array_buffer.rs Outdated
qjs::JS_GetRuntime(ctx.as_ptr()),
opaque,
ptr as *mut c_void,
0,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a constant like const FREE: qjs::size_t = 0;

Comment thread core/src/value/array_buffer.rs Outdated
ptr,
len as _,
// fixed-length buffer, not resizable
0,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a constant like const FIXED_SIZE: qjs::size_t = 0;

}

#[test]
fn transfer_to_different_length_preserves_vec_buffer() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory we could support the transfer by allocating a new vec if we want.

@richarddd
richarddd force-pushed the sync/quickjs-ng-bump branch from f763aca to 810b2b6 Compare August 29, 2026 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants