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

LTO enabled built node binary doesn't exit #40368

Closed
richardlau opened this issue Oct 7, 2021 · 3 comments · Fixed by #40631
Closed

LTO enabled built node binary doesn't exit #40368

richardlau opened this issue Oct 7, 2021 · 3 comments · Fixed by #40631
Assignees
Labels
linux Issues and PRs related to the Linux platform.

Comments

@richardlau
Copy link
Member

Version

v17.0.0-pre

Platform

Linux b4436f7227be 4.18.0-240.10.1.el8_3.x86_64 #1 SMP Wed Dec 16 03:30:52 EST 2020 x86_64 GNU/Linux (the gcc:11 container)

Subsystem

No response

What steps will reproduce the bug?

./configure --enable-lto --ninja
ninja -C out/Release
out/Release/node -p process.versions

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

Every time

What is the expected behavior?

Node.js prints the contents of process.versions and exits.

What do you see instead?

Contents of process.versions is printed but the process does not exit.

Additional information

Doesn't happen with regular non-LTO builds.

I've been testing inside the gcc:11 container (following the steps in https://github.com/nodejs/node/blob/master/.github/workflows/daily.yml). Please note that the build is succeeds but the GitHub workflow doesn't attempt to run the built binary (or run any tests). Interestingly the repl will exit but running scripts or tests does not.

Use of ninja isn't the issue -- the problem replicates if building with make.

Earlier versions of gcc can't build Node.js with LTO enabled (see #38570).

AFAICT this also occurs with the current v16.x-staging (e.g. before the V8 9.4 update). I haven't gone back any further yet.

@richardlau
Copy link
Member Author

Problem exists all the way back to Node.js 16.1.0.

Node.js 16.0.0 fails to compile with --enable-lto.

/usr/bin/ld: /tmp/ccB2LnG9.ltrans53.ltrans.o: in function `cppgc::internal::MarkerBase::VisitRoots(cppgc::EmbedderStackState)':
<artificial>:(.text+0xafa7): undefined reference to `PushAllRegistersAndIterateStack'
/usr/bin/ld: /tmp/ccB2LnG9.ltrans54.ltrans.o: in function `heap::base::Stack::IteratePointers(heap::base::StackVisitor*) const':
<artificial>:(.text+0x1486): undefined reference to `PushAllRegistersAndIterateStack'
collect2: error: ld returned 1 exit status

@iam-frankqiu iam-frankqiu added the linux Issues and PRs related to the Linux platform. label Oct 8, 2021
@kasicka
Copy link

kasicka commented Oct 8, 2021

Little off topic, but would it make sense to have LTO label?

@danbev danbev self-assigned this Oct 12, 2021
@danbev
Copy link
Contributor

danbev commented Oct 18, 2021

This issue only happens when Node.js is configured with --enable-lto and only for Release builds, not for Debug builds. The issue seems to be that there is an active libuv handle that is causing the event loop to block, hence the process not exiting/hanging.

This debugging session contains details about this issue and for those how don't want to read through all of that the summary is that GCC LTO was generating some incorrect code (not blaming GCC, or anyone else for that matter) which was causing this issue. After some investigating the issue pointed me to libuv/libuv#2588 and adding -fno-strict-aliasing to Node.js libuv build and the correct code is generated also for LTO builds and this issue is gone. I'll open a PR shortly for this.

danbev added a commit to danbev/node that referenced this issue Oct 27, 2021
This commit turns on `-fno-strict-aliasing` in libuv.

Fixes: nodejs#40368
Refs: libuv/libuv#1230
danbev added a commit to danbev/node that referenced this issue Oct 28, 2021
This commit turns on `-fno-strict-aliasing` in libuv.

Fixes: nodejs#40368
Refs: libuv/libuv#1230
nodejs-github-bot pushed a commit that referenced this issue Nov 16, 2021
This commit turns on `-fno-strict-aliasing` in libuv.

Fixes: #40368
Refs: libuv/libuv#1230

PR-URL: #40631
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Voltrex <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
targos pushed a commit that referenced this issue Nov 21, 2021
This commit turns on `-fno-strict-aliasing` in libuv.

Fixes: #40368
Refs: libuv/libuv#1230

PR-URL: #40631
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Voltrex <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
richardlau pushed a commit that referenced this issue Dec 13, 2021
This commit turns on `-fno-strict-aliasing` in libuv.

Fixes: #40368
Refs: libuv/libuv#1230

PR-URL: #40631
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Voltrex <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
richardlau pushed a commit that referenced this issue Dec 13, 2021
This commit turns on `-fno-strict-aliasing` in libuv.

Fixes: #40368
Refs: libuv/libuv#1230

PR-URL: #40631
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Voltrex <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
richardlau pushed a commit that referenced this issue Dec 13, 2021
This commit turns on `-fno-strict-aliasing` in libuv.

Fixes: #40368
Refs: libuv/libuv#1230

PR-URL: #40631
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Voltrex <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
danielleadams pushed a commit that referenced this issue Jan 10, 2022
This commit turns on `-fno-strict-aliasing` in libuv.

Fixes: #40368
Refs: libuv/libuv#1230

PR-URL: #40631
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Voltrex <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
danielleadams pushed a commit that referenced this issue Jan 10, 2022
This commit turns on `-fno-strict-aliasing` in libuv.

Fixes: #40368
Refs: libuv/libuv#1230

PR-URL: #40631
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Santiago Gimeno <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Voltrex <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linux Issues and PRs related to the Linux platform.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants