-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Incorrect code behavior on aarch64 #68812
Comments
Let’s try to have an MCVE for this? |
Hey ARM Group! This bug has been identified as a good "ARM candidate". cc @JamieCunliffe @joaopaulocarreiro @raw-bin @Stammark @vigoux |
Thanks! :)
We'll have a look and respond.
Cheers
…On Fri, Jun 12, 2020 at 7:31 PM rustbot ***@***.***> wrote:
Hey ARM Group! This bug has been identified as a good "ARM candidate".
In case it's useful, here are some [instructions] for tackling these sorts
of
bugs. Maybe take a look?
Thanks! <3
[instructions]:
https://rustc-dev-guide.rust-lang.org/notification-groups/arm.html
cc @JamieCunliffe <https://github.com/JamieCunliffe> @joaopaulocarreiro
<https://github.com/joaopaulocarreiro> @raw-bin
<https://github.com/raw-bin> @Stammark <https://github.com/Stammark>
@vigoux <https://github.com/vigoux>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#68812 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFMKYRJN6ZVUFWCMR4YXHTRWJYAZANCNFSM4KPNWSYA>
.
|
Hmm, if I understand what MCVE is, does this actually reproduce this for you? |
I ran that repo on my aarch64 box and it looked ok. It printed hello world when ran (both debug and release) and the test passes when run. Is there something else I have to do to get that to show the issue? |
@JamieCunliffe which rustc version did you use? |
Hi @berkus. A data point: I just had a play with your reproducer on a native AArch64 machine:
On the face of it, it appears that the test succeeds with nightly. There are some assumptions in the test that couple it to nightly so I couldn't test other versions. Can you confirm that this is expected ? Thanks |
@raw-bin yeah, I want to get to root of it, so from your output looks like this is fixed in the recent nightlies - I will give it a try. Still wanted know what version @JamieCunliffe used, but I guess it's too late for that - been a while. Give me a few days and I'll run the check on my Raspberry Pi with latest nightly and tell you how it went. |
@raw-bin looking at my cargo.toml I realised you have to run it in
|
@berkus. Just tried this with the same setup. Looks OK to me but please confirm:
|
Ok, I will run regression test from the moment I reported it to the latest compiler, gimme a few days pls. |
I've tested in the real project and it looks like the problem is not fixed:
this will run tests in qemu, tests print text stuff. if you run it now it will print garbage instead of text:
this code is miscompiled. Now go back 1 commit to
|
@berkus: It looks like you're not declaring some registers as being clobbered: You're writing to the Changing the clobbers line to |
Oh, thanks, @Aaron1011 , I missed this. Asm IS hard :) Switching from llvm_asm!() to asm!() should help here, I'll validate and then close. Thank you again! |
I'm an idiot! Replaced the code with
and it now works! Thank you! |
Fixes mis-compilation described in rust-lang/rust#68812.
The following code compiles and works correctly on
x86_64
. However, the same code when compiled foraarch64
withopt-level = "s"
does not work.https://github.com/berkus/mre-write_to
The culprit is the function show() in write_to.rs:44
(one-page version here -- this however is not enough for reproduction)
When used from the same module it correctly generates a &str from buffer slice. When used from another module the resulting str is "" (empty).
The original code location, where bug is easily reproducible by running
makers test
is here(Disclaimer: custom target file, should match LLVM layout for aarch64 however; custom linker script for OS kernel)
There, marking the function with
#[inline]
makes it work correctly at call sites other than the same module (for example, from here). Removing inline modifier makes it produce "" (empty) strs. It still works correctly from within the same module (e.g. local unit tests pass).Changing
opt-level
from "s" to 2 or 3 also fixes the issue.Replacing
from_utf8_unchecked
withfrom_utf8().unwrap()
causes different behavior. Now opt-levels 2 and "s" produce empty strs while opt-level 3 works as intended.It looks like code generation bug to me.
$ rustc --version
rustc 1.42.0-nightly (cd1ef39 2020-01-31)
Ready to provide more information or test possible fixes.
The text was updated successfully, but these errors were encountered: