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

segfault with shared builtin #46235

Closed
kapouer opened this issue Jan 17, 2023 · 3 comments
Closed

segfault with shared builtin #46235

kapouer opened this issue Jan 17, 2023 · 3 comments

Comments

@kapouer
Copy link
Contributor

kapouer commented Jan 17, 2023

Version

20.0.0-pre 15d673d

Platform

linux

Subsystem

builtins

What steps will reproduce the bug?

Build HEAD with --shared-builtin-cjs_module_lexer/lexer-path= pointing to a valid file path.
Run node without options.

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

No response

What do you see instead?

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff54892f8 in simdutf::utf16_length_from_utf8 (input=0x10005c630 "let source, pos, end;\nlet openTokenDepth,\n  templateDepth,\n  lastTokenPos,\n  lastSlashWasDivision,\n  templateStack,\n  templateStackDepth,\n  openTokenPosStack,\n  openClassPosStack,\n  nextBraceIsClass,\n"..., length=53562) at ../deps/simdutf/simdutf.cpp:4826
4826	  return active_implementation->utf16_length_from_utf8(input, length);
(gdb) bt
#0  0x00007ffff54892f8 in simdutf::utf16_length_from_utf8 (
    input=0x10005c630 "let source, pos, end;\nlet openTokenDepth,\n  templateDepth,\n  lastTokenPos,\n  lastSlashWasDivision,\n  templateStack,\n  templateStackDepth,\n  openTokenPosStack,\n  openClassPosStack,\n  nextBraceIsClass,\n"..., length=53562) at ../deps/simdutf/simdutf.cpp:4826
#1  0x00007ffff519ceb0 in node::builtins::BuiltinLoader::Add (id=0x7ffff74774e0 "internal/deps/cjs-module-lexer/lexer", 
    utf8source="let source, pos, end;\nlet openTokenDepth,\n  templateDepth,\n  lastTokenPos,\n  lastSlashWasDivision,\n  templateStack,\n  templateStackDepth,\n  openTokenPosStack,\n  openClassPosStack,\n  nextBraceIsClass,\n"...) at ../src/node_builtins.cc:271
#2  0x00007ffff519d4d0 in node::builtins::BuiltinLoader::AddExternalizedBuiltin (id=0x7ffff74774e0 "internal/deps/cjs-module-lexer/lexer", 
    filename=0x7ffff74774b0 "/usr/share/nodejs/cjs-module-lexer/lexer.js") at ../src/node_builtins.cc:266
#3  0x00007ffff519d63c in node::builtins::BuiltinLoader::BuiltinLoader (this=0x7ffff7f454f8 <node::builtins::BuiltinLoader::instance_>)
    at ../src/node_builtins.cc:40
#4  0x00007ffff50959c0 in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at ../src/node_builtins.cc:35
#5  _GLOBAL__sub_I_node_builtins.cc(void) () at ../src/node_builtins.cc:764

Additional information

No response

@anonrig
Copy link
Member

anonrig commented Jan 18, 2023

Related to the work that was done on this pull request

cc @addaleax @nodejs/startup

addaleax added a commit to addaleax/node that referenced this issue Jan 18, 2023
Using simdutf during startup can fail when compilation units are
linked in the wrong order by a static initialization order issue.

nodejs#46235 would also solve this,
but since that is a larger effort, this patch focuses on solving
the immediate problem. Alternatively, simdutf should arguably
be made usable during static initialization, but that is also not
as straightforward as this patch.

Fixes: nodejs#46235
addaleax added a commit to addaleax/node that referenced this issue Jan 18, 2023
Using simdutf during startup can fail when compilation units are
linked in the wrong order by a static initialization order issue.

nodejs#46235 would also solve this,
but since that is a larger effort, this patch focuses on solving
the immediate problem. Alternatively, simdutf should arguably
be made usable during static initialization, but that is also not
as straightforward as this patch.

Fixes: nodejs#46235
@addaleax
Copy link
Member

See #46256 – unfortunately it seems like simdutf is subject to the static initialization order fiasco…

@anonrig
Copy link
Member

anonrig commented Jan 19, 2023

Closing this issue, since simdutf pull request is merged.

@anonrig anonrig closed this as completed Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants