Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure v8 pointer compression + sandbox is enabled on 64bit native modules #34844

Merged
merged 2 commits into from Jul 8, 2022

Conversation

MarshallOfSound
Copy link
Member

We screwed up in #34157 and created logic that said "turn off pointer compression, unless we are on a 32 bit host, in which case also turn off pointer compression" 😭

This also takes the opportunity to align other new flags in E20 (specifically sandbox related flags) with their state in our v8 build. Without this alignment everything just falls apart randomly.

Notes: Fixed spontaneous crashing in native modules that depended on nan

@MarshallOfSound MarshallOfSound requested review from a team as code owners July 7, 2022 22:05
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jul 7, 2022
@MarshallOfSound MarshallOfSound added target/20-x-y and removed new-pr 🌱 PR opened in the last 24 hours labels Jul 7, 2022
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jul 7, 2022
@MarshallOfSound MarshallOfSound added the fast-track 🚅 Indicates that this PR is intended to bypass the 24 hour rule. Needs approval from Releases label Jul 7, 2022
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Jul 7, 2022
@MarshallOfSound MarshallOfSound added the semver/patch backwards-compatible bug fixes label Jul 7, 2022
Copy link
Member

@deepak1556 deepak1556 left a comment

Choose a reason for hiding this comment

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

@MarshallOfSound the patch was removed in favor of the pointer compression being generated as part of config.gypi

# Enabled in Chromium's V8.
if target_cpu in ('arm64', 'x64'):
args += ['--experimental-enable-pointer-compression']

@deepak1556
Copy link
Member

I can confirm pointer compression is enabled with config.gypi headers from main https://output.circle-artifacts.com/output/job/c9303ce5-21b4-4005-a222-4c0c502b93fc/artifacts/0/node_headers.tar.gz

@deepak1556 deepak1556 removed the fast-track 🚅 Indicates that this PR is intended to bypass the 24 hour rule. Needs approval from Releases label Jul 8, 2022
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jul 8, 2022
@VerteDinde
Copy link
Member

VerteDinde commented Jul 8, 2022

@deepak1556 I don't think the way pointer compression is being generated now is working quite right, unfortunately. If you try to compile a native module that uses nan using any Electron 20 alpha or beta build, the module crashes.

You can see an example of that happening here (sorry, this example is Windows-only): https://gist.github.com/VerteDinde/90c7f4555c0f7ba5fd374fed3f20cbb0 Adding #define V8_COMPRESS_POINTERS above #include <node.h> within the native module itself fixes the crashing.

@MarshallOfSound
Copy link
Member Author

MarshallOfSound commented Jul 8, 2022

@deepak1556 Ah I think I now understand the issue. We only upload a single node_headers bundle for each platform. But the value of enable_pointer_compression varies between architectures 🤔

This is why it works on CI for linux, because it uses the correct config.gypi 🤔 This change should probably still land because our current config.gypi has none of the sandbox flags and in fact has an incorrect one in one case in addition to fixing this pointer compression flag.

It should probably be considered a flaw in the generation of config.gypi if it generates arch-specific values without actually including a gypi arch check 🤔

@MarshallOfSound MarshallOfSound merged commit eba9d3f into main Jul 8, 2022
@MarshallOfSound MarshallOfSound deleted the enable-v8-pointer-compression branch July 8, 2022 08:06
@release-clerk
Copy link

release-clerk bot commented Jul 8, 2022

Release Notes Persisted

Fixed spontaneous crashing in native modules that depended on nan

@trop
Copy link
Contributor

trop bot commented Jul 8, 2022

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

@MarshallOfSound
Copy link
Member Author

We discussed this on Slack and concluded that if a slight adjustment (c556ce9) was made that this change was GTG

schetle pushed a commit to schetle/electron that referenced this pull request Nov 3, 2022
…ve modules (electron#34844)

* fix: ensure v8 pointer compression + sandbox is enabled on 64bit native modules

* build: rely on config.gypi to enable pointer compression
khalwa pushed a commit to solarwindscloud/electron that referenced this pull request Feb 22, 2023
…ve modules (electron#34844)

* fix: ensure v8 pointer compression + sandbox is enabled on 64bit native modules

* build: rely on config.gypi to enable pointer compression
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-pr 🌱 PR opened in the last 24 hours semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants