-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Rust compiler generates unaligned code, crashes sparc64-linux #53181
Comments
Aha, the Rust compiler is generating code with unaligned access again:
|
Here's the backtrace:
|
I think I now see the same on Solaris:
And the relevant core file:
|
What bothers me is that I am not getting any line numbers. |
It's #45679 again. |
Blast from the past. I've nominated this for discussion. I can't quite tell what the current status is -- I know @arielb1 wanted to land some changes to make derive work properly in the presence of |
Derive should mostly work for packed, I think. We should be emitting lints if it didn't work... |
First, rust/src/libsyntax_pos/span_encoding.rs Lines 24 to 30 in 0aa8d03
|
Discussed at the @rust-lang/compiler meeting today. We're going to mark this as P-medium for now. Can anyone with access to a sparc validate whether @glaubitz's workaround does indeed resolve the problem:
That would be very helpful, thanks! |
To really track this down more effectively we would need some way to reproduce -- nobody has access to SPARC hardware. |
Access to a SPARC porterbox can be provided to anyone interested in working on the problem.
… On Aug 23, 2018, at 5:16 PM, Niko Matsakis ***@***.***> wrote:
To really track this down more effectively we would need some way to reproduce -- nobody has access to SPARC hardware.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@nikomatsakis If you send me a private email with your public SSH key and your preferred username, I can create an account. FWIW, @karcherm has already been debugging this issue on the SPARC box. |
I think I'll be helping with the debugging. NOTE: I successfully reproduced everything locally. No SSH needed.
|
Just for record. I use the workaround on Solaris sparc and it works for me (with Firefox build). |
I did not get that much results yet. I can reproduce the unaligned access when building natively on sparc64, compiling 1.28 with 1.27 (after applying the __divdi patch). It's already the stage1 compiler that produces the fault. The relevant assembler code (inside
This is in the fist check of Also interesting might be the assembly of the preceding code:
It seems that the generation of faulting code only happens if certain inlining decisions are made "the appropriate way". I tried to make a minimal example of this by hand and failed to get this assembly out of a smaller code file. |
Out of curiosity, could #50960 ( |
I think I found it. This smells like an LLVM bug: %_587.sroa.4 = alloca [7 x i8], align 4
...
bb10.i: ; preds = %bb7.i
; this is *definitely* unaligned, being of offset 3 into a 4-aligned alloca
%_587.sroa.4.3.sroa_idx = getelementptr inbounds [7 x i8], [7 x i8]* %_587.sroa.4, i64 0, i64 3, !dbg !247022
br label %bb13.i, !dbg !247023
...
bb13.i: ; preds = %bb12.i, %bb11.i, %bb10.i
%_14.sroa.0.0.in.in.i = phi i8* [ %_587.sroa.7.0.sroa_cast427, %bb12.i ], [ %_587.sroa.7.0.sroa_cast427, %bb11.i ], [ %_587.sroa.4.3.sroa_idx, %bb10.i ]
%_14.sroa.6.0.i = phi i32 [ %_587.sroa.4.0._587.sroa.4.1.qpath_span.sroa.0.0.copyload.i, %bb12.i ], [ %_587.sroa.4.0._587.sroa.4.1.root_span.sroa.0.0.copyload.i, %bb11.i ], [ %5, %bb10.i ], !dbg !247028
%_14.sroa.0.0.in.i = bitcast i8* %_14.sroa.0.0.in.in.i to i32*, !dbg !247030
; but somehow LLVM is emitting a load with align 4 here
%_14.sroa.0.0.i = load i32, i32* %_14.sroa.0.0.in.i, align 4, !dbg !247028, !alias.scope !247025, !noalias !247026
%77 = icmp eq i64 %61, 0, !dbg !247031
br i1 %77, label %_ZN13rustc_resolve8Resolver31lint_if_path_starts_with_module17h8a282e5cd5cfe0bbE.exit, label %bb16.i, !dbg !247034 |
Opened https://bugs.llvm.org/show_bug.cgi?id=38707 - @nagisa @eddyb and co: could you try to get it fixed? |
Given that I reproduced the problem locally, I don't need the Sparc box anymore. Would be helpful if you could confirm that this is fixed after everything is done, though. |
@arielb1 Yes, will do once there is a patch. And sorry for the late reply and thanks a lot for digging this up! |
@arielb1 I can confirm that this patch fixes the issue: https://reviews.llvm.org/D51335 |
The LLVM fix had been merged into rustc. @glaubitz can you confirm that nightly works for you and close this issue? |
@arielb1 Yes, I'll test it now. |
Is this fixed? |
It has been fixed upstream: https://reviews.llvm.org/D51335 I can also confirm the patch works. I don't know whether it has been backported to Rust's own embedded LLVM copy though. |
The patch had been backported to nightly. Can you check that a recent nightly works on sparc? Or should I just close this issue? |
Seems to be fixed in nightly. I could build FWIW, there are now sparc64 porterboxes available in the gcc compile farm, both running Solaris and Linux, which can be used for testing and development of Rust on sparc64: Anyone who is an open source contributor can apply for an account. |
@arielb1 I can confirm that nighly works correctly. You're free to close this bug. |
With version 1.28, rust no longer builds on sparc64-linux and fails at stage1:
From the backtrace, it's not clear to me what the actual problem is. stage0 compiler is rust 1.27, cargo is 0.28. Both installed through Debian.
The text was updated successfully, but these errors were encountered: