Skip to content

inspector: fix crash when the IsolateData has no platform - #65818

Open
codebytere wants to merge 1 commit into
nodejs:mainfrom
codebytere:fix/embedder-inspector-null-platform
Open

inspector: fix crash when the IsolateData has no platform#65818
codebytere wants to merge 1 commit into
nodejs:mainfrom
codebytere:fix/embedder-inspector-null-platform

Conversation

@codebytere

@codebytere codebytere commented Sep 5, 2026

Copy link
Copy Markdown
Member

An embedder that creates its IsolateData without a MultiIsolatePlatform (node.h allows that and says only Workers need one) and keeps the inspector segfaults as soon as a node:inspector session is connected and the page logs: for console.log(), console.time() and the profilers V8 calls the inspector client's currentTimeMS(), and NodeInspectorClient::currentTimeMS() dereferenced isolate_data()->platform() unconditionally.

It now falls back to the wall clock when there is no platform, which is what NodePlatform::CurrentClockTimeMillis() returns anyway. This is the only place the inspector reaches for the platform; the Worker path already throws ERR_MISSING_PLATFORM_FOR_WORKER.

Tests: EnvironmentTest.InspectorWithoutPlatform creates an IsolateData without a platform, connects a session and calls console.time(); it segfaults before the change.

Refs: #21917


Disclosure: the code, test and this description were written by Claude Code, directed and reviewed by @codebytere.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/inspector

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. inspector Issues and PRs related to the V8 inspector protocol. needs-ci PRs that need a full CI run. labels Sep 5, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@codecov

codecov Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.19%. Comparing base (b0d56c7) to head (7656a6f).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65818      +/-   ##
==========================================
- Coverage   90.19%   90.19%   -0.01%     
==========================================
  Files         770      770              
  Lines      264410   264413       +3     
  Branches    50243    50236       -7     
==========================================
- Hits       238490   238477      -13     
- Misses      16924    16964      +40     
+ Partials     8996     8972      -24     
Files with missing lines Coverage Δ
src/inspector_agent.cc 82.02% <100.00%> (+0.07%) ⬆️

... and 36 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codebytere codebytere changed the title inspector: handle a null platform in the inspector client inspector: fix crash when the IsolateData has no platform Sep 5, 2026
An embedder that creates its IsolateData without a MultiIsolatePlatform
(allowed; node.h says only Workers need one) and keeps the inspector
segfaulted on the first `console.log()`, `console.time()` or profiler
use after a `node:inspector` session was connected: V8 calls the
inspector client's `currentTimeMS()` there, and
`NodeInspectorClient::currentTimeMS()` dereferenced
`isolate_data()->platform()` unconditionally.

Fall back to the wall clock when there is no platform, which is what
`NodePlatform::CurrentClockTimeMillis()` returns anyway.

Refs: nodejs#21917
Signed-off-by: Shelley Vohr <[email protected]>
@codebytere
codebytere force-pushed the fix/embedder-inspector-null-platform branch from da2dc82 to 7656a6f Compare September 5, 2026 17:56
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. inspector Issues and PRs related to the V8 inspector protocol. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants