Cosmopolitan clang.sh test fails on Alpine Linux

35 views
Skip to first unread message

Sebastian

unread,
Dec 22, 2021, 5:06:47 PM12/22/21
to
Hi everyone!

I ran into this problem building Cosmopolitan on Alpine Linux. The
actual compilation works fine, but one of the tests fail.

$ make MODE=dbg o/dbg/test/libc # this happens with all modes
[...successful tests...]
test/libc/release/clang.sh -Wno-unused-command-line-argument -Wno-incompatible-pointer-types-discards-qualifiers -no-canonical-prefixes -fdiagnostics-color=always
Segmentation fault
clang 9 EXITED WITH 139: test/libc/release/clang.sh -Wno-unused-command-line-argument -Wno-incompatible-pointer-types-discards-qualifiers -no-canonical-prefixes -fdiagnostics-color=always

The clang command itself runs successfully; it's the resulting binary
that segfaults. Note that when gcc is used instead of clang, the binary
successfully exits.

Here's a gdb session which may give some more info. Please let me know
if I should send anything else:

$ gdb o/dbg/test/libc/release/smokeclang.com.dbg
Reading symbols from o/dbg/test/libc/release/smokeclang.com.dbg...
(gdb) catch signal SIGSEGV
Catchpoint 1 (signal SIGSEGV)
(gdb) run
Starting program: /home/sebastian/src/archive/cosmopolitan/o/dbg/test/libc/release/smokeclang.com.dbg

Catchpoint 1 (signal SIGSEGV), 0x000000000040a657 in main ()
#0 0x000000000040a657 in main ()
No symbol table info available.
(gdb) disassemble # intel flavor
Dump of assembler code for function main:
0x000000000040a644 <+0>: push rbp
0x000000000040a645 <+1>: mov rbp,rsp
0x000000000040a648 <+4>: push r15
0x000000000040a64a <+6>: push r14
0x000000000040a64c <+8>: push rbx
0x000000000040a64d <+9>: sub rsp,0x18
0x000000000040a651 <+13>: mov rbx,rsi
0x000000000040a654 <+16>: mov r15d,edi
=> 0x000000000040a657 <+19>: mov rax,QWORD PTR fs:0x28
0x000000000040a660 <+28>: mov QWORD PTR [rbp-0x20],rax
0x000000000040a664 <+32>: call 0x40ad1e <showcrashreports>
0x000000000040a669 <+37>: mov rdi,QWORD PTR [rbx]
0x000000000040a66c <+40>: call 0x411bbc <strdup>
0x000000000040a671 <+45>: mov r14,rax
0x000000000040a674 <+48>: mov BYTE PTR [rax],0x5a
0x000000000040a677 <+51>: mov edi,0x450c24
0x000000000040a67c <+56>: mov esi,0x45351d
0x000000000040a681 <+61>: call 0x40c7f3 <fopen>
[...more disassembly...]
(gdb) info r
rax 0x459478 4559992
rbx 0x7fffffffe118 140737488347416
rcx 0x7fffffffe3c0 140737488348096
rdx 0x7fffffffe128 140737488347432
rsi 0x7fffffffe118 140737488347416
rdi 0x1 1
rbp 0x6fffffffffe0 0x6fffffffffe0
rsp 0x6fffffffffb0 0x6fffffffffb0
r8 0x1 1
r9 0xf 15
r10 0xe007fff7fe8 15395310239720
r11 0x297 663
r12 0x1 1
r13 0x7fffffffe118 140737488347416
r14 0x7fffffffe128 140737488347432
r15 0x1 1
rip 0x40a657 0x40a657 <main+19>
eflags 0x10202 [ IF RF ]
cs 0x33 51
ss 0x2b 43
ds 0x0 0
es 0x0 0
fs 0x0 0
gs 0x0 0
k0 0x0 0
k1 0x0 0
k2 0x0 0
k3 0x0 0
k4 0x0 0
k5 0x0 0
k6 0x0 0
k7 0x0 0

For reference, here's the disassembly when gcc is used instead of clang
(with all options the same):

Dump of assembler code for function main:
0x000000000040162e <+0>: push rbp
0x000000000040162f <+1>: mov rbp,rsp
0x0000000000401632 <+4>: push r14
0x0000000000401634 <+6>: mov r14d,edi
0x0000000000401637 <+9>: push r13
0x0000000000401639 <+11>: push r12
0x000000000040163b <+13>: push rbx
0x000000000040163c <+14>: mov rbx,rsi
0x000000000040163f <+17>: call 0x40acb6 <showcrashreports>
0x0000000000401644 <+22>: mov rdi,QWORD PTR [rbx]
0x0000000000401647 <+25>: call 0x4115b8 <strdup>
0x000000000040164c <+30>: mov esi,0x4533bd
0x0000000000401651 <+35>: mov edi,0x450ae4
0x0000000000401656 <+40>: mov BYTE PTR [rax],0x5a
0x0000000000401659 <+43>: mov r13,rax
0x000000000040165c <+46>: call 0x40c1ef <fopen>
[...more disassembly...]

My system libc is musl, though I'd assume that that doesn't make any
difference here. Any help for ways to fix this would be appreciated.
Thanks in advance!

- Sebastian
Reply all
Reply to author
Forward
0 new messages