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: don't export private V8 symbols that can cause native node modules to crash #18281

Merged
merged 9 commits into from Jun 3, 2019

Conversation

torycl
Copy link
Contributor

@torycl torycl commented May 13, 2019

Description of Change

This change stops private V8 symbols and internal CRT methods being exported. It fixes an issue where native node modules can import incorrect CRT methods and crash on Windows.

  • Windows specific
  • Directly disables exporting all symbols decorated with V8_EXPORT_PRIVATE
  • Removes std::basic_ostream from node.lib which causes crashes if node modules use std::ostream
  • Removes v8::internal from node.lib
  • Makes electron binary smaller
  • Native node module can be now linked with dynamic CRT on Windows

Checklist

Release Notes

Notes: Removed incorrectly published internal V8 symbols and CRT methods from node.lib, causing heap corruptions with node modules using the dynamic CRT on Windows.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label May 13, 2019
@miniak
Copy link
Contributor

miniak commented May 14, 2019

Related to #14617 (comment)

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label May 14, 2019
@alexeykuzmin alexeykuzmin changed the title fix: do not export v8 private symbols on Windows fix: do not export V8 private symbols on Windows May 14, 2019
@nornagon
Copy link
Member

@miniak that comment is about STL symbols, which this PR doesn't affect.

@torycl
Copy link
Contributor Author

torycl commented May 21, 2019

@miniak that comment is about STL symbols, which this PR doesn't affect.

Actually this PR is also about STL symbols. std::basic_ostream is in description of this PR from the beginning. I am trying to fix issue @miniak reported. That was originally the main goal of my work.
Removing private V8 symbols will make API surface smaller (less opportunities for mistakes) and it will also remove those stl symbols which causes crashes in node modules.
Reduced size of node.lib is nice bonus. Performance impact is very small. Build times are the same.

@torycl torycl changed the title fix: do not export V8 private symbols on Windows fix: don't export private V8 symbols that can cause native node modules to crash May 21, 2019
@nornagon
Copy link
Member

Oh huh. How does exporting the V8_EXPORT_PRIVATE symbols cause those STL symbols to be exported..? Perhaps I'm missing something about how dllexport works 🤔

@torycl
Copy link
Contributor Author

torycl commented May 22, 2019

Oh huh. How does exporting the V8_EXPORT_PRIVATE symbols cause those STL symbols to be exported..? Perhaps I'm missing something about how dllexport works 🤔

Exactly! I don't know. I have just tested it fixes our issues and it makes Electron 4 in Teams Desktop App much better. This is the reason I am quite hesitant to publish this change to full PR. First, I would like to know if this will be useful for somebody else. Or, in the meantime, I can find some better solution.

@miniak miniak marked this pull request as ready for review May 24, 2019 13:26
@miniak miniak requested a review from a team as a code owner May 24, 2019 13:26
@miniak miniak requested review from nornagon and ckerr May 24, 2019 13:28
@miniak miniak requested review from deepak1556 and zcbenz May 24, 2019 13:30
Copy link
Member

@nornagon nornagon left a comment

Choose a reason for hiding this comment

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

As written, I think this might impair our ability to run v8 tests in component mode. cc @alexeykuzmin

This could potentially be upstreamable if it were written as something like

#if !defined(HIDE_PRIVATE_SYMBOLS)
#ifdef BUILDING_V8_SHARED
#define V8_EXPORT_PRIVATE __declspec(dllexport)
#elif USING_V8_SHARED
#define V8_EXPORT_PRIVATE __declspec(dllimport)
#else
#define V8_EXPORT_PRIVATE
#endif
#else
#define V8_EXPORT_PRIVATE
#endif

@nornagon
Copy link
Member

Looks like the build is broken because master is broken. See #18443

@trop
Copy link
Contributor

trop bot commented Jun 4, 2019

A maintainer has manually backported this PR to "6-0-x", please check out #18619

@trop
Copy link
Contributor

trop bot commented Jun 4, 2019

A maintainer has manually backported this PR to "5-0-x", please check out #18620

@trop
Copy link
Contributor

trop bot commented Jun 4, 2019

A maintainer has manually backported this PR to "4-2-x", please check out #18621

jkleinsc pushed a commit that referenced this pull request Jun 4, 2019
ckerr pushed a commit that referenced this pull request Jun 4, 2019
ckerr pushed a commit that referenced this pull request Jun 4, 2019
@sofianguy sofianguy added this to Fixed in 5.0.3 in 5.0.x Jun 4, 2019
@sofianguy sofianguy added this to Fixed in 6.0.0-beta.6 in 6.1.x Jun 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
5.0.x
Fixed in 5.0.3
6.1.x
Fixed in 6.0.0-beta.6
Development

Successfully merging this pull request may close these issues.

None yet

7 participants