Skip to content

fix(napi): Update from_raw methods on External<T>#2453

Merged
Brooooooklyn merged 1 commit into
napi-rs:napi2from
zackradisic:napi2
Feb 4, 2025
Merged

fix(napi): Update from_raw methods on External<T>#2453
Brooooooklyn merged 1 commit into
napi-rs:napi2from
zackradisic:napi2

Conversation

@zackradisic

Copy link
Copy Markdown
Contributor

This commit was pushed the other day to copy my changes from #2449 into napi2 branch

Unfortunately the copied changes introduce a subtle bug which cause it to segfault on napi major version 2.

In this version of napi, the data pointer passed to napi_create_external() is the obj: *mut TaggedObject<T> field of External<T> (instead of *mut External<T> on main), whereas the External::from_raw_impl code assumes its not a *mut TaggedObject<T> but a *mut External<T>.

Because Rust may re-order the fields of a struct, directly casting *mut TaggedObject<T> -> *mut External<T> is invalid

@Brooooooklyn Brooooooklyn merged commit f9e073b into napi-rs:napi2 Feb 4, 2025
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