Skip to content

ARMv7-M: infinite recursion with __divmoddi4 / __mulodi4 #145

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

Closed
japaric opened this issue Mar 5, 2017 · 1 comment · Fixed by #146
Closed

ARMv7-M: infinite recursion with __divmoddi4 / __mulodi4 #145

japaric opened this issue Mar 5, 2017 · 1 comment · Fixed by #146

Comments

@japaric
Copy link
Member

japaric commented Mar 5, 2017

STR

let x: i64 = 6940082214040621058;
let y: i64 = 2305846955181360688;

let z = x % y;
// or
let z = sdiv::__divmoddi4(x, y, &mut 0);

with the target: thumbv7m-none-eabi.

The above program works fine (it terminates) with the x86_64-unknown-linux-gnu target.

Meta

$ rustc -V
rustc 1.17.0-nightly (b1e31766d 2017-03-03)
@japaric
Copy link
Member Author

japaric commented Mar 5, 2017

Actually, the problem seems to be mulodi4 (divmoddi4 calls mulodi4). This recurses infinitely:

let r: i64 = 3;
let b: i64 = 2305846955181360688;

let x = r * b;
// or
let x = mul::__mulodi4(r, b, &mut 0);

@japaric japaric changed the title ARMv7-M: infinite recursion with __divmoddi4 ARMv7-M: infinite recursion with __divmoddi4 / __mulodi Mar 5, 2017
@japaric japaric changed the title ARMv7-M: infinite recursion with __divmoddi4 / __mulodi ARMv7-M: infinite recursion with __divmoddi4 / __mulodi4 Mar 5, 2017
japaric pushed a commit that referenced this issue Mar 6, 2017
on ARMv7-M processors, divmoddi4 was calling mulodi4 and mulodi4 was calling
divmoddi4 leading to infinite recursion. This commit breaks the cycle by using
wrapping multiplication in divmoddi4.

fixes #145
bors added a commit that referenced this issue Mar 6, 2017
fix infinite recursion in divmoddi4 / mulodi4

on ARMv7-M processors, divmoddi4 was calling mulodi4 and mulodi4 was calling
divmoddi4 leading to infinite recursion. This commit breaks the cycle by using
wrapping multiplication in divmoddi4.

fixes #145

r? @alexcrichton
@bors bors closed this as completed in #146 Mar 7, 2017
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 a pull request may close this issue.

1 participant