nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
106.46k stars 29.01k forks source link

segfault in generated sea executable #53916

Closed kaduvert closed 2 weeks ago

kaduvert commented 1 month ago

Version

22.5.0

Platform

Linux machine 6.9.9-1-MANJARO #1 SMP PREEMPT_DYNAMIC Fri Jul 12 10:32:52 UTC 2024 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

follow official guide to create sea the files i have: https://github.com/kaduvert/nodejs-issue-53916 base.js is used with node --experimental-sea-config sea-config.json to create base.blob (base.js is specified in my package.json) which is then used with npx postject ./hello a base.blob --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 to create 'hello' (included in the report.zip file) 'node' is the node executable used, which does not segfault

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

always occurs

What is the expected behavior? Why is that the expected behavior?

no segfault

What do you see instead?

segfault

Additional information

No response

RedYetiDev commented 1 month ago

Can you provide the specific stack trace (if any).

Additionally, can you reproduce on 22.5.0?

kaduvert commented 1 month ago

so it still occurs on 22.5.0, i checked by using the binary from nodejs website (no aur update yet) and the stack trace is...: i don't know how to get the stack trace. this is the output which i describe as 'segfault': image

kaduvert commented 1 month ago

so following some tutorial i found that i should install gdb and type backtrace, this is the output: image

But do not rely on me please, i have provided the binaries for analysis, you people probably know how to do it, i don't.

RedYetiDev commented 1 month ago

@nodejs/single-executable

joyeecheung commented 1 month ago

Can you upload the reproduction to a GitHub repository?

joyeecheung commented 1 month ago

so following some tutorial i found that i should install gdb and type backtrace, this is the output:

gdb -c is used to load the coredump, not the executable. To use gdb to run an executable, run gdb ./hello, and then in the loaded repl, run run.

kaduvert commented 1 month ago

image

Can you upload the reproduction to a GitHub repository?

yeah... probably, but can't you just download the zip?

joyeecheung commented 1 month ago

Navigating in the browser would be safer than downloading arbitrary zip and trying to reproduce it. (Not guaranteeing that I would volunteer to help fixing this bug, but it might also raise your chances of having another volunteer to look into this bug).

kaduvert commented 1 month ago

ok https://github.com/kaduvert/nodejs-issue-53916

CGQAQ commented 2 weeks ago

which is then used with npx postject ./hello a base.blob --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2

Your command was wrong. On Linux it should be npx postject hello NODE_SEA_BLOB ./dist/base.blob --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2

Notice the NODE_SEA_BLOB instead of a, see official docs

image

CGQAQ commented 2 weeks ago

@RedYetiDev this issue should be closed as expected


~ cp ../../out/Release/node hello
~ ./hello
Welcome to Node.js v23.0.0-pre.
Type ".help" for more information.
> 
(To exit, press Ctrl+C again or Ctrl+D or type .exit)
> 
~ npx postject hello NODE_SEA_BLOB ./dist/base.blob     --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 
Start injection of NODE_SEA_BLOB in hello...
warning: Can't find string offset for section name '.note'
💉 Injection done!
~ ./hello
1

~ cp ../../out/Release/node hello
~ npx postject hello a ./dist/base.blob     --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 
Start injection of a in hello...
warning: Can't find string offset for section name '.note'
💉 Injection done!
~ ./hello
Segmentation fault
kaduvert commented 2 weeks ago

v22.4.1:

$ ./node
Welcome to Node.js v22.4.1.
Type ".help" for more information.
> 
(To exit, press Ctrl+C again or Ctrl+D or type .exit)
> 
$ npx postject ./node NODE_SEA_BLOB base.blob \
    --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
Start injection of NODE_SEA_BLOB in ./node...
warning: Can't find string offset for section name '.note'
💉 Injection done!
$ ./node
zsh: segmentation fault (core dumped)  ./node

using latest nightly binary:

$ ./node
Welcome to Node.js v23.0.0-nightly20240820561bc87c76.
Type ".help" for more information.
> 
(To exit, press Ctrl+C again or Ctrl+D or type .exit)
> 
$ npx postject ./node NODE_SEA_BLOB base.blob \
    --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
Start injection of NODE_SEA_BLOB in ./node...
warning: Can't find string offset for section name '.note.100'
warning: Can't find string offset for section name '.note.100'
warning: Can't find string offset for section name '.note.100'
warning: Can't find string offset for section name '.note.100'
warning: Can't find string offset for section name '.note.100'
warning: Can't find string offset for section name '.note'
warning: Can't find string offset for section name '.note.100'
warning: Can't find string offset for section name '.note.100'
warning: Can't find string offset for section name '.note.100'
💉 Injection done!
$ ./node
(node:6557) Warning: Code cache data rejected.
(Use `node --trace-warnings ...` to show where the warning was created)
1
$

so it's fixed in the latest nightly build, but it hasn't been fixed by telling me i used the wrong command, because that didn't matter in v22.4.1. But he is right in that you have to use NODE_SEA_BLOB in the command else it won't work

thank you people, i'm closing this now