mailing list of musl libc
 help / color / mirror / code / Atom feed
From: "Kenny, Joseph P" <>
To: "" <>
Subject: [musl] C++ segfault on riscv64
Date: Fri, 18 Mar 2022 16:41:56 +0000	[thread overview]
Message-ID: <> (raw)

[-- 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 --]

             reply	other threads:[~2022-03-18 16:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-18 16:41 Kenny, Joseph P [this message]
2022-03-18 16:48 ` [musl] Re: [EXTERNAL] " Kenny, Joseph P
2022-03-19  8:44   ` Szabolcs Nagy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).