-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
zig libc
crashes with out of memory error on loongarch64
#21468
Comments
also see: ziglang/zig-bootstrap#164 (comment) |
Does it happen under QEMU? |
I bootstrapped another version with ReleaseSafe mode and the error is different
Here is the backtrace output. (gdb) r libc
Starting program: /home/yxd/opt/zig/musl/zig libc
[New LWP 59504]
[New LWP 59505]
[New LWP 59506]
[New LWP 59507]
[New LWP 59508]
thread 59502 panic: incorrect alignment
Thread 1 "zig" received signal SIGABRT, Aborted.
raise (sig=<optimized out>) at /Users/yxd/playspace/zig-bootstrap/out/host/lib/zig/libc/musl/src/signal/raise.c:12
warning: 12 /Users/yxd/playspace/zig-bootstrap/out/host/lib/zig/libc/musl/src/signal/raise.c: No such file or directory
(gdb) bt
#0 raise (sig=<optimized out>) at /Users/yxd/playspace/zig-bootstrap/out/host/lib/zig/libc/musl/src/signal/raise.c:12
#1 0x000000000a8dc530 in abort () at /Users/yxd/playspace/zig-bootstrap/out/host/lib/zig/libc/musl/src/exit/abort.c:11
#2 0x0000000009e04490 in posix.abort () at /Users/yxd/playspace/zig-bootstrap/out/host/lib/zig/std/posix.zig:706
#3 0x000000000a840068 in debug.panicImpl (trace=0x0, first_trace_addr=...) at /Users/yxd/playspace/zig-bootstrap/out/host/lib/zig/std/io/Writer.zig:19
#4 0x00000000099fef58 in builtin.default_panic (error_return_trace=0x0, ret_addr=...) at /Users/yxd/playspace/zig-bootstrap/out/host/lib/zig/std/builtin.zig:885
#5 0x0000000009c247c4 in posix.mmap (ptr=<optimized out>, length=528, prot=<optimized out>, flags=<optimized out>, fd=<optimized out>, offset=0)
at /Users/yxd/playspace/zig-bootstrap/out/host/lib/zig/std/posix.zig:4706
#6 0x0000000009bc1a58 in crypto.tlcsprng.tlsCsprngFill () at /Users/yxd/playspace/zig-bootstrap/out/host/lib/zig/std/crypto/tlcsprng.zig:64
#7 0x0000000009c89488 in Random.bytes () at /Users/yxd/playspace/zig-bootstrap/out/host/lib/zig/std/Random.zig:55
#8 Random.int__anon_48074 () at /Users/yxd/playspace/zig-bootstrap/out/host/lib/zig/std/Random.zig:109
#9 Compilation.update (comp=0x7ffff7f9d350, main_progress_node=...) at Compilation.zig:2122
#10 0x0000000009c8fc14 in main.updateModule (comp=0x7ffff7f9d350, color=auto, prog_node=...) at main.zig:4499
#11 0x0000000009a2af0c in main.jitCmd (gpa=..., arena=..., options=...) at main.zig:5586
#12 0x00000000099feb7c in main.mainArgs (arena=...) at main.zig:303
#13 main.main () at main.zig:199
#14 start.callMain () at /Users/yxd/playspace/zig-bootstrap/out/host/lib/zig/std/start.zig:619
#15 start.callMainWithArgs () at /Users/yxd/playspace/zig-bootstrap/out/host/lib/zig/std/start.zig:579
#16 start.main (c_argc=<optimized out>, c_argv=<optimized out>, c_envp=<optimized out>) at /Users/yxd/playspace/zig-bootstrap/out/host/lib/zig/std/start.zig:594 updateI got the reason of this problem, my loongarch64 machine's memory page size is not 16KiB but 4KiB.
I will check this with linux distribution's packagers. |
I haven't try it on qemu. I will check the page size thing first. (The two errors happen on two different machines (with same linux distribution (loongarchlinux)) with different zig optimize values (ReleaseFast vs. ReleaseSafe (no strip))) |
Ok, seems like this would be addressed by #20511. |
OK, I will wait for this PR merged and check again. However, I bootstrapped a 4KiB page size version of loongarch64-linux-musl zig for my 4KiB page size loongarchlinux machine. For this version,
It will crash if this environment variable is not set.
I checked the code here So it seems that running |
Backtrace of
is like this after I disabled strip in jitCmd function for ReleaseFast. (gdb) r libc
Starting program: /home/yxd/.cache/zig/o/524096a6eb1b49fde3b21dc390171077/libc libc
Program received signal SIGSEGV, Segmentation fault.
0x0000000001083b6c in posix.openatZ (dir_fd=<optimized out>, file_path=0x7ffffffef9b8 "/usr/bin/env", flags=<optimized out>, mode=0)
at /home/yxd/opt/zig/musl-debug/lib/std/posix.zig:1775
1775 switch (errno(rc)) {
(gdb) bt
#0 0x0000000001083b6c in posix.openatZ (dir_fd=<optimized out>, file_path=0x7ffffffef9b8 "/usr/bin/env", flags=<optimized out>, mode=0)
at /home/yxd/opt/zig/musl-debug/lib/std/posix.zig:1775
#1 0x00000000010753c0 in fs.Dir.openFileZ (sub_path=0x7ffffffef9b8 "/usr/bin/env", flags=...) at /home/yxd/opt/zig/musl-debug/lib/std/fs/Dir.zig:882
#2 fs.Dir.openFile (flags=...) at /home/yxd/opt/zig/musl-debug/lib/std/fs/Dir.zig:829
#3 0x000000000107c93c in fs.openFileAbsolute () at /home/yxd/opt/zig/musl-debug/lib/std/fs.zig:280
#4 zig.system.detectAbiAndDynamicLinker (os=..., query=...) at /home/yxd/opt/zig/musl-debug/lib/std/zig/system.zig:1037
#5 zig.system.resolveTargetQuery (query=...) at /home/yxd/opt/zig/musl-debug/lib/std/zig/system.zig:348
#6 zig.resolveTargetQueryOrFatal (target_query=...) at /home/yxd/opt/zig/musl-debug/lib/std/zig.zig:613
#7 libc.main () at libc.zig:66
#8 0x00000000010752a4 in start.callMain () at /home/yxd/opt/zig/musl-debug/lib/std/start.zig:619
#9 start.callMainWithArgs () at /home/yxd/opt/zig/musl-debug/lib/std/start.zig:579
#10 start.posixCallMainAndExit (argc_argv_ptr=<optimized out>) at /home/yxd/opt/zig/musl-debug/lib/std/start.zig:535
#11 0x0000000000000000 in ?? ()
Backtrace stopped: frame did not save the PC and in frame 0, rc = 4 |
Zig Version
0.14.0-dev.1622+2ac543388
Steps to Reproduce and Observed Behavior
musl
orgnu
.zig libc
on a loongarch64 linux machine with the bootstrappedzig
Expected Behavior
zig libc
returns correct libc related information on loongarch64 like x86_64 or aarch64 onesThe text was updated successfully, but these errors were encountered: