Skip to content

fix: enable blink gc plugin - #50465

Merged
deepak1556 merged 1 commit into
mainfrom
robo/blink_gc_plugin
Apr 10, 2026
Merged

deepak1556 merged 1 commit into
mainfrom
robo/blink_gc_plugin

Conversation

@deepak1556

Copy link
Copy Markdown
Member

Description of Change

Enables GC plugin built into upstream clang to capture cppgc issues at compile time. The goal is to prevent issues like 19f4f38

Currently the plugin is built with restricted set of namespaces and directories so whatever changes made in this PR were from https://source.chromium.org/chromium/chromium/src/+/main:tools/clang/blink_gc_plugin/BadPatternFinder.cpp that is always available.

Since we don't build our own clang, having custom directories supported as a plugin argument in upstream would be the next best step to get the full benefits of the plugin for gin and electron directories. I will followup on that.

Release Notes

Notes: none

@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Mar 24, 2026
@deepak1556
deepak1556 force-pushed the robo/blink_gc_plugin branch from bf3dd16 to 2ccfc95 Compare March 24, 2026 19:06
@deepak1556
deepak1556 marked this pull request as draft March 24, 2026 19:17
@deepak1556

Copy link
Copy Markdown
Member Author

having custom directories supported as a plugin argument in upstream would be the next best step to get the full benefits of the plugin for gin and electron directories. I will followup on that.

https://chromium-review.googlesource.com/c/chromium/src/+/7699392

@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Mar 25, 2026
@deepak1556

Copy link
Copy Markdown
Member Author

change has landed upstream, now need to wait for the next clang roll (since the plugin is built into clang) which happens approx every 2 weeks per https://chromium.googlesource.com/chromium/src/+/main/docs/clang.md#using-plugins.

@deepak1556

Copy link
Copy Markdown
Member Author

@deepak1556

Copy link
Copy Markdown
Member Author

We have a subrevision change landed before the actual roll https://chromium-review.googlesource.com/c/chromium/src/+/7722698, this is sufficient. Its available from 148.0.7770.0, so the next roll after #50599 will unblock this PR

@deepak1556
deepak1556 force-pushed the robo/blink_gc_plugin branch from 2ccfc95 to a681df2 Compare April 3, 2026 19:45
@deepak1556 deepak1556 changed the title chore: address blink gc plugin errors (part I) chore: address blink gc plugin errors Apr 4, 2026
@deepak1556
deepak1556 force-pushed the robo/blink_gc_plugin branch 3 times, most recently from 26ec7ef to 9170874 Compare April 9, 2026 02:13
@deepak1556 deepak1556 added semver/patch backwards-compatible bug fixes target/41-x-y PR should also be added to the "41-x-y" branch. target/42-x-y PR should also be added to the "42-x-y" branch. and removed semver/none no-backport labels Apr 9, 2026
@deepak1556 deepak1556 added semver/none no-backport and removed semver/patch backwards-compatible bug fixes target/41-x-y PR should also be added to the "41-x-y" branch. target/42-x-y PR should also be added to the "42-x-y" branch. labels Apr 9, 2026
@deepak1556
deepak1556 force-pushed the robo/blink_gc_plugin branch 2 times, most recently from 01edb47 to 8760029 Compare April 9, 2026 03:19
@deepak1556

Copy link
Copy Markdown
Member Author

The changes need backport but without the clang plugin stuff, better to do a manual backport to relevant branches once merged.

@deepak1556
deepak1556 marked this pull request as ready for review April 9, 2026 20:36
@deepak1556 deepak1556 changed the title chore: address blink gc plugin errors fix: enable blink gc plugin Apr 9, 2026
@deepak1556 deepak1556 added semver/patch backwards-compatible bug fixes and removed semver/none labels Apr 9, 2026

@ckerr ckerr 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.

This is pretty impressive stuff. ❤️

I want to give this review proper attention, I will review this first thing tomorrow morning

@ckerr

ckerr commented Apr 9, 2026

Copy link
Copy Markdown
Member

@deepak1556 seems like some of the changes to shell/ should get tropped at least to 42-x-y? If so, should this PR be split into >1 piece?

@deepak1556

Copy link
Copy Markdown
Member Author

I was planning to backport necessary changes into respective branches manually after merge but I think I can split them up now.

@deepak1556

deepak1556 commented Apr 10, 2026 •

Copy link
Copy Markdown
Member Author

Extracted the powermonitor crash and menu spec changes, I will leave the rest in this PR and manually backport post merge.

@ckerr ckerr 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.

I love this. Thanks for adding this.

One remaining chore to sync patches/ but otherwise LVGTM

@deepak1556
deepak1556 force-pushed the robo/blink_gc_plugin branch from dc24fde to c1bd070 Compare April 10, 2026 16:24
Key fixes:
- Replace `base::WeakPtrFactory` with `gin::WeakCellFactory` in
  MenuMac, MenuViews, and NetLog, since weak pointers to cppgc-managed
  objects must go through weak cells
- Replace `v8::Global<v8::Value>` with `cppgc::Persistent<Menu>` for
  the menu reference in BaseWindow
- Stop using `gin_helper::Handle<T>` with cppgc types; use raw `T*`
  and add a `static_assert` to prevent future misuse
- Add proper `Trace()` overrides for Menu, MenuMac, MenuViews, and
  NetLog to ensure cppgc members are visited during garbage collection
- Replace `SelfKeepAlive` prevent-GC mechanism in Menu with a
  `cppgc::Persistent` prevent-GC captured in `BindSelfToClosure`
- Introduce `GC_PLUGIN_IGNORE` macro to suppress
  known-safe violations: mojo::Remote fields, ObjC bridging pointers,
  and intentional persistent self-references
- Mark `ArgumentHolder` as `CPPGC_STACK_ALLOCATED()` in both Electron's
  and gin's function_template.h to silence raw-pointer-to-GC-type
  warnings
@deepak1556
deepak1556 force-pushed the robo/blink_gc_plugin branch from c1bd070 to 53a9b34 Compare April 10, 2026 16:27
@deepak1556
deepak1556 merged commit 9be03cb into main Apr 10, 2026
62 checks passed
@deepak1556
deepak1556 deleted the robo/blink_gc_plugin branch April 10, 2026 18:21
@release-clerk

release-clerk Bot commented Apr 10, 2026

Copy link
Copy Markdown

No Release Notes

@trop

trop Bot commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

@deepak1556 has manually backported this PR to "42-x-y", please check out #50914

@trop

trop Bot commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

@deepak1556 has manually backported this PR to "41-x-y", please check out #50915

@trop trop Bot added in-flight/41-x-y merged/42-x-y PR was merged to the "42-x-y" branch. and removed in-flight/42-x-y labels Apr 10, 2026
@trop trop Bot added merged/41-x-y PR was merged to the "41-x-y" branch. and removed in-flight/41-x-y labels Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged/41-x-y PR was merged to the "41-x-y" branch. merged/42-x-y PR was merged to the "42-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants