|
Message-ID: <323912A7-59BB-43DF-B250-4C93BE06797A@sandia.gov>
Date: Fri, 18 Mar 2022 16:41:56 +0000
From: "Kenny, Joseph P" <jpkenny@...dia.gov>
To: "musl@...ts.openwall.com" <musl@...ts.openwall.com>
Subject: C++ segfault on riscv64
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 musl.cc 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
#include<stdio.h>
int main(int argc, char **argv) {
printf("Hello\n");
return 0;
}
$ riscv32-linux-musl-gcc -static -g -Og hello.c -o hello
$ qemu-riscv32 hello
Hello
C++ segfaults:
$ riscv32-linux-musl-g++ -static -g -Og hello.cc -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?
Thanks
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)
Content of type "text/html" skipped
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.