[CSKY] segmentation fault in `__multi3`
I have written a toolchain for csky in Rust at https://github.com/rust-lang/rust/pull/113658 before.
However, when I run a simple Rust program with u128, like this
fn main() {
let a = 0x12345678876543219876543223456789_u128;
println!("{a}");
}
I can compile the program successfully. However, I got a segmentation fault when I run it. It seems that -mdouble-float is not enabled. So can anyone will help to add this feature? or guide me add it?
(I'm not sure if I'm right about the above Issue, if anyone have any idea, please fell free to tell me. Thanks!)
@benshi001 @zixuan-wu I noticed that you two provide many commits to csky, so I want to know if you can give me some advice? Thanks.
Besides, contact to me If I could add your WeChat. My email is [email protected] . Thanks!
Double float is not support in CSKY target. The segmentation fault is agnostic in such high level view and can't know the exact issue.
I have written a toolchain for
cskyinRustat rust-lang/libc#3301 before.However, when I run a simple Rust program with u128, like this
fn main() { let a = 0x12345678876543219876543223456789_u128; println!("{a}"); }I got a segmentation fault. It seems that
-mdouble-floatis not enabled. So can anyone will help to add this feature? or guide me add it?(I'm not sure if I'm right about the above Issue, if anyone have any idea, please fell free to tell me. Thanks!)
@benshi001 @zixuan-wu I noticed that you two provide many commits to
csky, so I want to know if you can give me some advice? Thanks.Besides, contact to me If I could add your WeChat. My email is [email protected] . Thanks!
Could you please offer an .ll file and the command line options of llc ? I am not familiar with rust.
Could you please offer an
.llfile and the command line options ofllc? I am not familiar with rust.
Yeah, I can offer a .ll file. However, It has 714 lines and I have no idea about how to make a MCVE, because I have little experience about low-level debugging.
float_cal-e4847f7eee567be8.txt
and I think using llc without any options is enough.
./llc float_cal-e4847f7eee567be8.ll
Could you please offer an
.llfile and the command line options ofllc? I am not familiar with rust.Yeah, I can offer a
.llfile. However, It has 714 lines and I have no idea about how to make a MCVE, because I have little experience about low-level debugging.float_cal-e4847f7eee567be8.txt
and I think using
llcwithout any options is enough../llc float_cal-e4847f7eee567be8.ll
I think it's about int128 type. It looks like a int128 num is split into 4 int32 nums in backend and to load/store with 4 times load/store in sequence. So there is no issue as I go through the .ll roughly and the seg fault may not be related to int128.
I did some research on the executable file. I debug it with gdb, and I got seg fault in __multi3.
the following is the position where it crash and the registers before it crash.
would it help?
Could you give me some direction on why it got seg fault?
Thanks!
I did some research on the executable file. I debug it with gdb, and I got seg fault in
__multi3.the following is the position where it crash and the registers before it crash.
would it help?
Could you give me some direction on why it got seg fault?
Thanks!
From your info, it triggered by loading from address( r1 + 0x8 )which is 0x23456789 + 0x8. You can check this address and see whether it's a legal address such as data or bss section.
And normally there is little possibility error occurred in __multi3 library, and it's more likely the argument passed into __multi3 got wrong.
which is 0x23456789 + 0x8.
Thanks , It's what I confused. It seems that 0x23456789 is not an address, it's a part of my u128 value(which is 0x12345678876543212345678998765432)
fn main() {
let a = 0x12345678876543219876543223456789_u128;
println!("{a}");
}
Should my next step be to find out why 0x23456789 give to r1?
which is 0x23456789 + 0x8.
Thanks , It's what I confused. It seems that 0x23456789 is not an address, it's a part of my u128 value(which is 0x12345678876543212345678998765432)
fn main() { let a = 0x12345678876543219876543223456789_u128; println!("{a}"); }Should my next step be to find out why 0x23456789 give to
r1?
Right. Normally r0,r1 consist of first argument of __multi3 because the first argument is i64 type.
@EugeneZelenko Could you help to chage the label
@Dirreke: To which one(s)?
@Dirreke: To which one(s)?
Thanks! I guess it might be backend:CSKY and bug?
Thanks! After some tests, I think #68971 is different from #21245 . I can not simply disable UINTTOFP_I128_FXX like __multi3 easily.
When program call the u128 related builtin functions like __multi3 and __floattidf on CSKY, the value of the parameters will be passed to the function, but the function will regard it as an address. It result a SIGSEGV.
I have no idea about how to fix it. Could you give me some advice? @zixuan-wu @benshi001
there's nothing to do. It's error in codegen of rust. thank all of you
