Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CSKY] segmentation fault in __multi3 #68971

Closed
Dirreke opened this issue Oct 13, 2023 · 13 comments
Closed

[CSKY] segmentation fault in __multi3 #68971

Dirreke opened this issue Oct 13, 2023 · 13 comments
Labels
backend:CSKY invalid Resolved as invalid, i.e. not a bug

Comments

@Dirreke
Copy link

Dirreke commented Oct 13, 2023

I have written a toolchain for csky in Rust at rust-lang/rust#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 mingyang_ge@163.com . Thanks!

@EugeneZelenko EugeneZelenko added question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! and removed new issue labels Oct 13, 2023
@zixuan-wu
Copy link
Contributor

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.

@benshi001
Copy link
Member

I have written a toolchain for csky in Rust at 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-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 mingyang_ge@163.com . Thanks!

Could you please offer an .ll file and the command line options of llc ? I am not familiar with rust.

@Dirreke
Copy link
Author

Dirreke commented Oct 16, 2023

Could you please offer an .ll file and the command line options of llc ? 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

@zixuan-wu
Copy link
Contributor

Could you please offer an .ll file and the command line options of llc ? 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

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.

@Dirreke
Copy link
Author

Dirreke commented Oct 17, 2023

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.
mmexport1697537599959.jpg

would it help?


Could you give me some direction on why it got seg fault?

Thanks!

@zixuan-wu
Copy link
Contributor

zixuan-wu commented Oct 18, 2023

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. mmexport1697537599959.jpg

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.

@Dirreke
Copy link
Author

Dirreke commented Oct 18, 2023

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?

@zixuan-wu
Copy link
Contributor

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.

@Dirreke Dirreke changed the title [CSKY] missing double-float feature [CSKY] segmentation fault in __multi3 Oct 20, 2023
@Dirreke Dirreke changed the title [CSKY] segmentation fault in __multi3 [CSKY] segmentation fault in __multi3 Oct 20, 2023
@Dirreke
Copy link
Author

Dirreke commented Oct 22, 2023

@EugeneZelenko Could you help to chage the label

@EugeneZelenko
Copy link
Contributor

@Dirreke: To which one(s)?

@Dirreke
Copy link
Author

Dirreke commented Oct 22, 2023

@Dirreke: To which one(s)?

Thanks! I guess it might be backend:CSKY and bug?

@EugeneZelenko EugeneZelenko added backend:CSKY and removed question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! labels Oct 22, 2023
@Dirreke
Copy link
Author

Dirreke commented Oct 23, 2023

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

@Dirreke
Copy link
Author

Dirreke commented Oct 25, 2023

there's nothing to do. It's error in codegen of rust. thank all of you

@Dirreke Dirreke closed this as completed Oct 25, 2023
@EugeneZelenko EugeneZelenko added the invalid Resolved as invalid, i.e. not a bug label Oct 25, 2023
@EugeneZelenko EugeneZelenko closed this as not planned Won't fix, can't repro, duplicate, stale Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:CSKY invalid Resolved as invalid, i.e. not a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants