-
Notifications
You must be signed in to change notification settings - Fork 16.2k
fix: don't export private V8 symbols that can cause native node modules to crash #18281
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3850c23
fix: do not export v8 private symbols on Windows
7778844
Using safer comment which will not affect rest of the line
f9398b6
Better patch description
8153374
Merge remote-tracking branch 'electron/master'
777a855
Patch modified so component build is not affected
975c76b
Merge remote-tracking branch 'electron/master'
541ead3
Patch properly exported
f8d98be
Added comment about removing patch
5252c89
Merge remote-tracking branch 'electron/master'
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
patches/common/v8/do_not_export_private_v8_symbols_on_windows.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Tomas Rycl <torycl@microsoft.com> | ||
Date: Mon, 13 May 2019 15:48:48 +0200 | ||
Subject: Do not export private V8 symbols on Windows | ||
|
||
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. | ||
It also reduces size of node.lib by 75%. | ||
|
||
torycl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This patch can be safely removed if, when it is removed, `node.lib` does not | ||
contain any standard C++ library exports (e.g. `std::ostringstream`). | ||
|
||
diff --git a/BUILD.gn b/BUILD.gn | ||
index 315c7079ed488461a456aff799b4d1f17b896150..0f668eae73686c02a7133df31a79e8a0a7b77707 100644 | ||
--- a/BUILD.gn | ||
+++ b/BUILD.gn | ||
@@ -273,6 +273,10 @@ config("internal_config") { | ||
":v8_header_features", | ||
] | ||
|
||
+ if (!is_component_build && is_electron_build) { | ||
+ defines += [ "HIDE_PRIVATE_SYMBOLS" ] | ||
+ } | ||
+ | ||
if (is_component_build || is_electron_build) { | ||
defines += [ "BUILDING_V8_SHARED" ] | ||
} | ||
diff --git a/src/base/macros.h b/src/base/macros.h | ||
index ad70e9820ddb4a63639ca7738c1836cb87766db5..d40be9b57294583f74594d88d9b7d7b937b2db3c 100644 | ||
--- a/src/base/macros.h | ||
+++ b/src/base/macros.h | ||
@@ -414,13 +414,17 @@ bool is_inbounds(float_t v) { | ||
#ifdef V8_OS_WIN | ||
|
||
// Setup for Windows shared library export. | ||
+#if defined(HIDE_PRIVATE_SYMBOLS) | ||
+#define V8_EXPORT_PRIVATE | ||
+#else //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 | ||
+#else //!(BUILDING_V8_SHARED || USING_V8_SHARED) | ||
#define V8_EXPORT_PRIVATE | ||
-#endif // BUILDING_V8_SHARED | ||
+#endif | ||
+#endif | ||
|
||
#else // V8_OS_WIN | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.