Skip to content

fix: throw instead of crashing when a method is called with a foreign native receiver - #54313

Merged
MarshallOfSound merged 1 commit into
45-x-yfrom
fix/45-x-y/wrong-receiver-null-deref
Sep 24, 2026
Merged

MarshallOfSound merged 1 commit into
45-x-yfrom
fix/45-x-y/wrong-receiver-null-deref

Conversation

@MarshallOfSound

Copy link
Copy Markdown
Member

Description of Change

Before: on 45-x-y and earlier, calling a native method with a receiver of a different native type, for example webContents.isLoading.call(session.defaultSession), segfaults the main process. The old wrapper lookup checks the internal field count and then dereferences field 0, but cppgc-managed wrappers (session, app, …) have the same field count with null fields.

After: the lookup returns null for those objects and the call throws TypeError: Illegal invocation, the same as it already does for a plain object or on main (where this code path was removed in #53758). Adds a spec that crashed the runner before the fix.

Release branches only; not applicable to main.

Checklist

Release Notes

Notes: Fixed a main process crash when a native API method was called with a this value of a different native type; it now throws a TypeError.

… native receiver

DeprecatedWrapperInfo::From assumed that any object with the expected
number of internal fields had a wrapper info in field 0. cppgc-managed
gin::Wrappable objects (session, app, ...) have the same field count but
leave the fields null, so calling e.g. webContents.isLoading with a
session as the receiver dereferenced null in the main process instead of
throwing 'Illegal invocation'.
@MarshallOfSound MarshallOfSound added semver/patch backwards-compatible bug fixes target/44-x-y PR should also be added to the "44-x-y" branch. target/43-x-y PR should also be added to the "43-x-y" branch. backport-check-skip Skip trop's backport validity checking 45-x-y labels Sep 24, 2026
@MarshallOfSound MarshallOfSound self-assigned this Sep 24, 2026
@MarshallOfSound
MarshallOfSound enabled auto-merge (squash) September 24, 2026 19:49
@MarshallOfSound
MarshallOfSound merged commit ad1681d into 45-x-y Sep 24, 2026
103 checks passed
@MarshallOfSound
MarshallOfSound deleted the fix/45-x-y/wrong-receiver-null-deref branch September 24, 2026 21:16
@release-clerk

release-clerk Bot commented Sep 24, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed a main process crash when a native API method was called with a this value of a different native type; it now throws a TypeError.

@trop

trop Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "44-x-y", please check out #54315

@trop

trop Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "43-x-y", please check out #54316

@trop trop Bot added in-flight/43-x-y merged/43-x-y PR was merged to the "43-x-y" branch. merged/44-x-y PR was merged to the "44-x-y" branch. and removed target/44-x-y PR should also be added to the "44-x-y" branch. target/43-x-y PR should also be added to the "43-x-y" branch. in-flight/43-x-y in-flight/44-x-y labels Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

45-x-y backport-check-skip Skip trop's backport validity checking merged/43-x-y PR was merged to the "43-x-y" branch. merged/44-x-y PR was merged to the "44-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants