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

uWS (uWebSockets) seg faults when bundled with pkg #82

Open
mikeseese opened this issue Aug 1, 2024 · 4 comments
Open

uWS (uWebSockets) seg faults when bundled with pkg #82

mikeseese opened this issue Aug 1, 2024 · 4 comments

Comments

@mikeseese
Copy link

What version of pkg are you using?

5.12.0

What version of Node.js are you using?

18.20.3

What operating system are you using?

Windows

What CPU architecture are you using?

x86_64

What Node versions, OSs and CPU architectures are you building for?

node18-win-x64

Describe the Bug

If I create a bundled exe with pkg that includes https://github.com/uNetworking/uWebSockets.js, simply just requiring the module, there is a segfault. I've noticed this issue for Node20 (target of Node20) and 18. I haven't tried other versions.

This error doesn't occur when running in Node without pkg, so my guess is the uWS author will state this is an issue with pkg.

Here is the stack trace I'm seeing:

PID 80500 received SIGSEGV for address: 0x4126efc
SymInit: Symbol-SearchPath: '.;D:\work\test-pkg-uws;D:\work\test-pkg-uws\dist;C:\WINDOWS;C:\WINDOWS\system32;SRV*C:\websymbols*http://msdl.microsoft.com/download/symbols;', symOptions: 530, UserName: 'seese'
OS-Version: 10.0.22621 () 0x100-0x1
D:\work\test-pkg-uws\node_modules\segfault-handler\src\StackWalker.cpp (941): StackWalker::ShowCallstack
D:\work\test-pkg-uws\node_modules\segfault-handler\src\segfault-handler.cpp (242): segfault_handler
00007FF93F867F5A (ntdll): (filename not available): RtlGetLengthWithoutLastFullDosOrNtPathElement
00007FF93F80E642 (ntdll): (filename not available): RtlFindCharInUnicodeString
00007FF93F89403E (ntdll): (filename not available): KiUserExceptionDispatcher
0000000004126EFC ((module-name not available)): (filename not available): (function-name not available)
00007FF6C2D1C01C (node): (filename not available): inflateValidate
00007FF6C1CF40B1 (node): (filename not available): uv_loop_new
00007FF80FCC0A39 (uws_win32_x64_108): (filename not available): (function-name not available)
00007FF80FCFADBE (uws_win32_x64_108): (filename not available): node::MultiIsolatePlatform::operator=
00007FF80FCC8A54 (uws_win32_x64_108): (filename not available): node_register_module_v108
00007FF6038D8EB2 (test-pkg-uws): (filename not available): node::Buffer::New
00007FF6039209E5 (test-pkg-uws): (filename not available): node_api_throw_syntax_error
00007FF6038D9A05 (test-pkg-uws): (filename not available): node::Buffer::New
00007FF60430D15D (test-pkg-uws): (filename not available): v8::internal::Builtins::code
00007FF60430CD69 (test-pkg-uws): (filename not available): v8::internal::Builtins::code
00007FF60430D02C (test-pkg-uws): (filename not available): v8::internal::Builtins::code
00007FF60430CE90 (test-pkg-uws): (filename not available): v8::internal::Builtins::code
00007FF6043F2731 (test-pkg-uws): (filename not available): v8::internal::SetupIsolateDelegate::SetupHeap

Expected Behavior

To not crash when loading uWebSockets.js.

To Reproduce

  1. Clone https://github.com/mikeseese/test-pkg-uws
  2. yarn
  3. yarn test

Note the segfault stack trace printed out instead of seeing hello printed to the screen.

@mikeseese
Copy link
Author

I've tested as far back as https://github.com/uNetworking/uWebSockets.js/releases/tag/v20.22.0 (April 2023) and still see the same stack trace; this isn't a recent regression in uWS.

@robertsLando
Copy link
Member

Unfortunately I cannot do much here, could be something related to the patched node version we are using, would be curious to check if the same happens with other arch/os

@mikeseese
Copy link
Author

Sounds good. I no longer need it as I reverted away from using uWS for now, so I'm not sure if I'm inclined to dive into debugging the Node runtime to figure out what's causing the error. The next time I want to package uWS will either be when Bun is more mature or Node SEA is stable 🤷.

At a minimum, keeping this issue open could help others find the blocker if they run into the same scenario.

@robertsLando
Copy link
Member

robertsLando commented Aug 2, 2024

Yeah I'm keeping an eye on Node SEA too as I think that's the future but I'm not sure if and when it will be mature enough to work out of the box like pkg does :(

What I'm missing right now from SEA is an easy way to handle .node native addons and other assets, when that's working using it paired with esbuild to bundle everything on a single file could be an option, then it would be good to skip the esbuild step (that could be hard to configure on complex app) and let SEA find all the files to bundle and create the exe like pkg does

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants