Skip to content

Commit 3f7bdc5

Browse files
bnoordhuisMylesBorins
authored andcommitted
deps: cherry-pick e020aae394 from V8 upstream
Original commit message: Work around glibc thread-local storage bug glibc before 2.17 has a bug that makes it impossible to execute binaries that have single-byte thread-local variables: % node --version node: error while loading shared libraries: cannot allocate memory in static TLS block Work around that by making the one instance in the V8 code base an int. See: https://sourceware.org/bugzilla/show_bug.cgi?id=14898 See: nodesource/distributions#513 See: nodejs/build#809 Change-Id: Iefd8009100cd93e26cf8dc5dc03f2d622b423385 Reviewed-on: https://chromium-review.googlesource.com/612351 Commit-Queue: Ben Noordhuis <[email protected]> Reviewed-by: Eric Holk <[email protected]> Cr-Commit-Position: refs/heads/master@{#47400} PR-URL: #14913 Ref: nodejs/build#809 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Nikolai Vavilov <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent f1284d3 commit 3f7bdc5

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

deps/v8/src/trap-handler/handler-shared.cc

+8-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ namespace v8 {
2323
namespace internal {
2424
namespace trap_handler {
2525

26-
THREAD_LOCAL bool g_thread_in_wasm_code = false;
26+
// We declare this as int rather than bool as a workaround for a glibc bug, in
27+
// which the dynamic loader cannot handle executables whose TLS area is only
28+
// 1 byte in size; see https://sourceware.org/bugzilla/show_bug.cgi?id=14898.
29+
THREAD_LOCAL int g_thread_in_wasm_code = false;
30+
31+
static_assert(sizeof(g_thread_in_wasm_code) > 1,
32+
"sizeof(thread_local_var) must be > 1, see "
33+
"https://sourceware.org/bugzilla/show_bug.cgi?id=14898");
2734

2835
size_t gNumCodeObjects = 0;
2936
CodeProtectionInfoListEntry* gCodeObjects = nullptr;

deps/v8/src/trap-handler/trap-handler.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ inline bool UseTrapHandler() {
6565
return FLAG_wasm_trap_handler && V8_TRAP_HANDLER_SUPPORTED;
6666
}
6767

68-
extern THREAD_LOCAL bool g_thread_in_wasm_code;
68+
extern THREAD_LOCAL int g_thread_in_wasm_code;
6969

7070
inline bool IsThreadInWasm() { return g_thread_in_wasm_code; }
7171

0 commit comments

Comments
 (0)