Skip to content

src: enter isolate before destructing IsolateData - #51138

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
bnoordhuis:fix51129
Dec 25, 2023
Merged

src: enter isolate before destructing IsolateData#51138
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
bnoordhuis:fix51129

Conversation

@bnoordhuis

Copy link
Copy Markdown
Member

MVP fix for a worker_threads crash where ~WorkerThreadData() -> ~IsolateData() -> Isolate::DetachCppHeap() kicks off a round of garbage collection that expects an entered isolate.

No test because the crash is not reliably reproducable but the bug is pretty clearly described in the linked issue and is obvious once you see it, IMO.

Fixes: #51129

MVP fix for a worker_threads crash where ~WorkerThreadData() ->
~IsolateData() -> Isolate::DetachCppHeap() kicks off a round of
garbage collection that expects an entered isolate.
No test because the crash is not reliably reproducable but the bug
is pretty clearly described in the linked issue and is obvious once
you see it, IMO.
Fixes: nodejs#51129
@nodejs-github-botnodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. worker Issues and PRs related to Worker support. labels Dec 12, 2023
@lpincalpinca added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 13, 2023
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 13, 2023
@nodejs-github-bot

This comment was marked as outdated.

@targos

Copy link
Copy Markdown
Member

@nodejs/cpp-reviewers

@lpinca

Copy link
Copy Markdown
Member

@nodejs/workers

@joyeecheungjoyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 14, 2023
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 14, 2023
@nodejs-github-bot

This comment was marked as outdated.

@debadree25debadree25 added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 15, 2023
@joyeecheung

joyeecheung commented Dec 16, 2023

Copy link
Copy Markdown
Member

By the way it just occurred to me - consider this non-blocking - why can we not just do this directly in the IsolateData destructor instead? That would correct this for the embedder-facing node::FreeIsolateData() as well.

@bnoordhuis

Copy link
Copy Markdown
MemberAuthor

I considered that but I'm not 100% sure it won't cause deadlocks.

@juanarboljuanarbol left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@jasnelljasnell added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 22, 2023
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 22, 2023
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@lpincalpinca added the commit-queue Add this label to land a pull request using GitHub Actions. label Dec 25, 2023
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Dec 25, 2023
@nodejs-github-bot
nodejs-github-bot merged commit aa87b77 into nodejs:mainDec 25, 2023
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in aa87b77

RafaelGSS pushed a commit that referenced this pull request Jan 2, 2024
MVP fix for a worker_threads crash where ~WorkerThreadData() ->
~IsolateData() -> Isolate::DetachCppHeap() kicks off a round of
garbage collection that expects an entered isolate.
No test because the crash is not reliably reproducable but the bug
is pretty clearly described in the linked issue and is obvious once
you see it, IMO.
Fixes: #51129
PR-URL: #51138
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
@RafaelGSSRafaelGSS mentioned this pull request Jan 2, 2024
richardlau pushed a commit that referenced this pull request Mar 25, 2024
MVP fix for a worker_threads crash where ~WorkerThreadData() ->
~IsolateData() -> Isolate::DetachCppHeap() kicks off a round of
garbage collection that expects an entered isolate.
No test because the crash is not reliably reproducable but the bug
is pretty clearly described in the linked issue and is obvious once
you see it, IMO.
Fixes: #51129
PR-URL: #51138
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
@richardlaurichardlau mentioned this pull request Mar 25, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.c++Issues and PRs that require attention from people who are familiar with C++.needs-ciPRs that need a full CI run.workerIssues and PRs related to Worker support.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

worker_threads: race and crash on worker exit

14 participants

@bnoordhuis@nodejs-github-bot@targos@lpinca@joyeecheung@Qard@santigimeno@benjamingr@tniessen@UlisesGascon@legendecas@juanarbol@jasnell@debadree25