-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[GR-34769] Stack depth more limited with musl static native image, how to increase? #3398
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
Comments
As discussed with @gradinac, it seems to be an issue with the stack size of the main thread. As a workaround you can set the main thread's stack size like this: public class JavaRecur {
public static void foo(int x) {
if (x % 10000 == 0)
System.out.println(x);
foo(x+1);
}
public static void main(String [] args) throws InterruptedException {
Runnable runnable =
() -> { foo(0); };
Thread thread = new Thread(null, runnable, "foo", 10000000);
thread.start();
thread.join();
}
} Compiled with musl this prints all the way up to The unclear bit:
|
From Slack: Aleksandar Gradinac 5 minutes ago Aleksandar Gradinac 5 minutes ago |
According to our internal ticket GR-34769 this was fixed in October 2022. |
According to oracle/graal#3398, the bug necessitating this workaround was fixed in October 2022.
The bug necessitating this workaround was fixed in October 2022. For details: oracle/graal#3398
Describe the issue
I am using GraalVM 21.1.0 Java 11 CE to compile static binaries for linux using musl
1.2.2-1
(from Debian unstable). The stack depth is much more limited than a similar binary compiled without--static
. I tried to increase the limit with"-H:CCompilerOption=-Wl,-z,stack-size=10485760"
but to no avail.Steps to reproduce the issue
Compile the following
JavaRecur.java
program and run it:You will likely see that the stack depth is limited to around
2500
while with the non-static binary we can go up to around260000
.Note that a basic C program like this:
behaves pretty much the same with
gcc
andmusl-gcc
(without passing linker options to either):Similar output with
musl-gcc -o main --static main.c
.Describe GraalVM and your environment:
More details
See https://gist.github.com/borkdude/3a36ccc5dd186ac9f1a761b9b7b7cd36 for a stack trace that contains more info.
See https://gist.github.com/borkdude/8395ac49d7b90ebe4b9a911565304b3d for options passed to the linker printed with
"-H:CCompilerOption=--verbose"
and"-H:+TraceNativeToolUsage"
.Workaround
Compile with
-H:CCompilerOption=-Wl,-z,stack-size=10485760
(or higher stack size if needed)and then start your main program in a thread instead.
This is surely a workaround, the main issue should still be addressed.
/cc @gradinac
The text was updated successfully, but these errors were encountered: