-
Notifications
You must be signed in to change notification settings - Fork 4.7k
test --isolate: retarget NapiEnv at new global; --parallel: abort on worker panic, never retry #30216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
test --isolate: retarget NapiEnv at new global; --parallel: abort on worker panic, never retry #30216
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0666772
test --isolate: retarget NapiEnv at new global; --parallel: abort on …
robobun 8ffa838
[autofix.ci] apply automated fixes
autofix-ci[bot] 19503d4
review: VM assert in retargetGlobalObject; repoint macro_event_loop.g…
robobun 1160318
describeStatus: format exit code into a caller-provided buffer instea…
robobun 5a6dcdf
Coordinator: doc fixes; panic-abort kills inflight workers even if --…
robobun a8d09c8
test(30205): strip BUN_JSC_validateExceptionChecks from spawned subpr…
robobun 0e0573f
doc: correct rare_data.cleanup_hooks retarget rationale (eql() is dea…
robobun c62ff55
CI fixes: skip napi-UAF tests on Windows; suppress intentional SIGABR…
robobun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| // Non-experimental (NAPI_VERSION 8) addon that napi_wrap()s each object it's | ||
| // handed. Because nm_version != NAPI_VERSION_EXPERIMENTAL, the finalizer is | ||
| // deferred to a NapiFinalizerTask on the event loop rather than run inside GC | ||
| // sweep. Under `bun test --isolate`, objects rooted on the old global only | ||
| // become collectable once the swap gcUnprotect()s it; their finalizers then | ||
| // run while the *next* file is loading, with a NapiEnv whose m_globalObject | ||
| // used to point at the now-dead old global. See test/regression/issue/30205. | ||
|
|
||
| #include <js_native_api.h> | ||
| #include <node_api.h> | ||
| #include <stdlib.h> | ||
|
|
||
| #define CALL(env, call) \ | ||
| do { \ | ||
| if ((call) != napi_ok) { \ | ||
| napi_throw_error((env), NULL, "napi call failed: " #call); \ | ||
| return NULL; \ | ||
| } \ | ||
| } while (0) | ||
|
|
||
| static void finalize(napi_env env, void *data, void *hint) { | ||
| (void)env; | ||
| (void)hint; | ||
| free(data); | ||
| } | ||
|
|
||
| // wrap(obj) -> obj — attaches a deferred finalizer and returns the same | ||
| // object so the caller can root it (e.g. on globalThis). | ||
| static napi_value wrap(napi_env env, napi_callback_info info) { | ||
| size_t argc = 1; | ||
| napi_value argv[1]; | ||
| CALL(env, napi_get_cb_info(env, info, &argc, argv, NULL, NULL)); | ||
| if (argc < 1) { | ||
| napi_throw_type_error(env, NULL, "wrap: expected one argument"); | ||
| return NULL; | ||
| } | ||
| int *data = (int *)malloc(sizeof *data); | ||
| *data = 1; | ||
| CALL(env, napi_wrap(env, argv[0], data, finalize, NULL, NULL)); | ||
| return argv[0]; | ||
| } | ||
|
|
||
| NAPI_MODULE_INIT(/* napi_env env, napi_value exports */) { | ||
| napi_value fn; | ||
| CALL(env, napi_create_function(env, "wrap", NAPI_AUTO_LENGTH, wrap, NULL, &fn)); | ||
| CALL(env, napi_set_named_property(env, exports, "wrap", fn)); | ||
| return exports; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.