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

Fix panic due to overflow in riscv.rs and int/shift.rs #521

Merged
merged 1 commit into from
Mar 25, 2023

Conversation

taiki-e
Copy link
Member

@taiki-e taiki-e commented Mar 22, 2023

I ran into this while testing riscv32i-unknown-none-elf with -Z build-std=core,alloc.

panicked at 'attempt to add with overflow', /Users/taiki/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.87/src/riscv.rs:42:17

(Can be reproduced by cloning semihosting repo, comment out this line, and run ./tools/no-std riscv32i-unknown-none-elf)

@taiki-e
Copy link
Member Author

taiki-e commented Mar 23, 2023

I found another panic due to overflow on the other targets (thumbv5te-none-eabi) as well. I will update the PR to include a fix for them later.

panicked at 'attempt to subtract with overflow', /Users/taiki/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.87/src/int/shift.rs:15:39
panicked at 'attempt to subtract with overflow', /Users/taiki/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.87/src/int/shift.rs:60:69

(Can be reproduced by cloning portable-atomic repo, comment out this line, and run ./tools/no-std thumbv5te-none-eabi)

@taiki-e taiki-e marked this pull request as draft March 23, 2023 08:25
@taiki-e taiki-e changed the title Fix overflow in riscv __mulsi3 and __muldi3 Fix panic due to overflow in riscv.rs and int/shift.rs Mar 23, 2023
@taiki-e taiki-e marked this pull request as ready for review March 23, 2023 13:01
@Amanieu Amanieu merged commit 831f1f4 into rust-lang:master Mar 25, 2023
@taiki-e taiki-e deleted the riscv-mul branch March 25, 2023 18:55
@davidben
Copy link

A related issue we uncovered when we hit a variation on this in Arm: llvm/llvm-project#62743

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants