mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] C++ segfault on riscv64
@ 2022-03-18 16:41 Kenny, Joseph P
  2022-03-18 16:48 ` [musl] Re: [EXTERNAL] " Kenny, Joseph P
  0 siblings, 1 reply; 3+ messages in thread
From: Kenny, Joseph P @ 2022-03-18 16:41 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 2431 bytes --]

I’m getting segfaults with musl for C++ code on riscv64. I have tested mipsel using qemu user mode as described below and found no issues.

I’m cross-compiling using the latest riscv64-linux-musl-cross.tgz (23-Nov-2021) from on x86_64/Fedora 35. I have confirmed that I get the following behavior for both riscv64 hardware and qemu user mode.

C is fine:

$ cat hello.c
int main(int argc, char **argv) {
return 0;
$ riscv32-linux-musl-gcc -static -g -Og hello.c -o hello
$ qemu-riscv32 hello

C++ segfaults:

$ riscv32-linux-musl-g++ -static -g -Og -o hello
$ qemu-riscv32 hello
Segmentation fault (core dumped)

GDB confirms the segfault in __dynamic_cast on both qmeu and riscv64 hardware. I’ll paste in the assembly below. Segfault occurs on the last instruction shown [ld      a5,0(a0)].

I’ve taken this as far as my skills allow. Any ideas what’s going on here or how to debug further?


000000000007d38e <__dynamic_cast>:
   7d38e:       c55d                    beqz    a0,7d43c <__dynamic_cast+0xae>
   7d390:       00053803                ld      a6,0(a0)
   7d394:       715d                    addi    sp,sp,-80
   7d396:       fc26                    sd      s1,56(sp)
   7d398:       ff083703                ld      a4,-16(a6)
   7d39c:       ff883783                ld      a5,-8(a6)
   7d3a0:       84b6                    mv      s1,a3
   7d3a2:       972a                    add     a4,a4,a0
   7d3a4:       6314                    ld      a3,0(a4)
   7d3a6:       4805                    li      a6,1
   7d3a8:       1812                    slli    a6,a6,0x24
   7d3aa:       e802                    sd      zero,16(sp)
   7d3ac:       ec42                    sd      a6,24(sp)
   7d3ae:       e0a2                    sd      s0,64(sp)
   7d3b0:       842a                    mv      s0,a0
   7d3b2:       ff86b503                ld      a0,-8(a3)
   7d3b6:       e486                    sd      ra,72(sp)
   7d3b8:       f84a                    sd      s2,48(sp)
   7d3ba:       f44e                    sd      s3,40(sp)
   7d3bc:       f052                    sd      s4,32(sp)
   7d3be:       e402                    sd      zero,8(sp)
   7d3c0:       04f51663                bne     a0,a5,7d40c <__dynamic_cast+0x7e>
   7d3c4:       611c                    ld      a5,0(a0)

[-- Attachment #2: Type: text/html, Size: 9150 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-03-19  8:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-18 16:41 [musl] C++ segfault on riscv64 Kenny, Joseph P
2022-03-18 16:48 ` [musl] Re: [EXTERNAL] " Kenny, Joseph P
2022-03-19  8:44   ` Szabolcs Nagy

Code repositories for project(s) associated with this public inbox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).