test(inspector): test report progress case#50
Draft
tony-go wants to merge 6 commits into
Draft
Conversation
Signed-off-by: Tony Gorez <gorez.tony@gmail.com>
Signed-off-by: Tony Gorez <gorez.tony@gmail.com>
Signed-off-by: Tony Gorez <gorez.tony@gmail.com>
Signed-off-by: Tony Gorez <gorez.tony@gmail.com>
Signed-off-by: Tony Gorez <gorez.tony@gmail.com>
Signed-off-by: Tony Gorez <gorez.tony@gmail.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
HeapProfiler.takeHeapSnapshotwithreportProgress: truecrashes the process withSIGSEGV. The inspector channel delivers V8 protocol messages by synchronously invoking the embedder callback, which re-enters JavaScript. During heap snapshot generation V8 emitsHeapProfiler.reportHeapSnapshotProgressnotifications while the stack is being scanned and JS execution is disallowed, so re-entering JS there crashes.This makes the Chrome DevTools Memory panel unusable against an inspected process, since it requests progress reporting when taking a snapshot.
Root cause
js_inspector_channel_s::send()used to call the response callback inline:The crashing path (bare runtime, arm64):
Omitting params, passing
{}, orreportProgress: falseall avoid the crash because they don't emit progress notifications mid-generation.Approach
Treat the channel as a deferred transport:
send()never re-enters JavaScript, it only queues the (already converted) message. Delivery happens viaflush()at the two points where re-entering JS is provably safe:dispatchProtocolMessage()injs_inspector_s::send(): responses to a client request are delivered synchronously, preserving the existing request/response behaviour (no observable change; existing tests untouched).js_env_s::run_macrotasks()— notifications emitted from a V8 task (heap snapshot progress/chunks) are delivered between macrotasks.takeHeapSnapshotschedules the snapshot as a task, so its messages aren't in the queue at point (1) and are delivered at point (2), out of the forbidden window.Note on
flushProtocolNotifications(): V8's own hook is left as a no-op on purpose. V8 calls it fromHeapSnapshotProgress::ReportProgressValueso delivering there would re-crash.Ref: https://gist.github.com/vietthang/3fa883343ff10a2ea4cf2a9b6a9e5b5b