-
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
debug no-optimize OS X make check-fast exposes segfault in rustc #9129
Comments
Bisecting the contents of run_pass_stage2.rc, the problem down to one particular test:
|
Further narrowing reveals that the problem seems to be when we have either of labelled
|
Is the segfault/bus error due to infinite recursion? |
@huonw no, I already considered that, but the stack isn't that large, especially once you try on one of the narrowed test cases. My current hypothesis is that it has something to do with these bits of code, like: (update; correction to below, I have cut-and-pasted some code into
but I have not figured out what is actually wrong there yet, if anything. |
Further discovery: the problem seems to be the subexpression The cute thing here is that since I am seeing the same bug on both
#[cfg(labelled_again)]
pub fn main() { 'foo: loop { loop 'foo; } }
#[cfg(labelled_break)]
pub fn main() { 'foo: loop { break 'foo; } }
#[cfg(labelled_for)]
pub fn main() { 'foo: for i in range(1,10) { } } The relevant modification to the code in
The first starred case, with
I'm guessing one next step would be to compare the generated code for the two different closures. |
cc @jbclements for the injection. cc @nikomatsakis for the potential bogosity in borrowck (right?) |
This small program also causes a similar bus error, and @pnkfelix seemed to think it might be related:
|
@jbclements I'll check about master. Just to confirm, you did use the same set of CONFIGURE_ARGS that I had in the description, right? (Just double-checking.) |
I think I am using only --enable-debug in my compiles. |
Servo is hitting this problem, so this is a workaround for a lack of a real solution.
@pnkfelix do we have any better idea what the generated code is doing that is causing to crash? could be a bug in borrowck, but it's hard to say |
@nikomatsakis no, I don't have a real idea yet. Kind of scary that so few of us can replicate in the small isolated cases (so far just me and @lkuper have said so). My plan for next step is to actually compare the two generated code sequences within the closure, but I did not get a chance to do that today. I will either attempt to do it over the weekend (might be tricky, got family in town) or on Monday. |
Servo is hitting this problem, so this is a workaround for lack of a real solution. No tests because I couldn't actually reproduce the problem with either of the testcases in #9129
Status report: I've made side-by-side comparisons of both the generated LLVM bitcode (as .ll disassembly) and also the generated machine code. Its too much material to post here, but this is the link: https://gist.github.com/pnkfelix/6579174 (You might notice some small differences between e.g. the .rs input and the generated LLVM, because the .rs input has some changes to e.g. insert I do not know .ll well enough to immediately tell whether the bug lies in trans (i.e. if we are generated bogus input to LLVM) or if this is an LLVM bug (i.e. they are mistranslating our input). The problem seems to be that the generated code is not correctly extracting the address for the In particular: for the LLVM input of the broken case, the main differences are that:
|
At this point I'm pretty confident this is exposing a bug in LLVM. After making a standalone test case (see updated bug description), I was able to generate bitcode from Starting from the broken .ll code, I discovered:
Here's the source input for this experiment: https://gist.github.com/pnkfelix/6580915 (the basis of the .ll code is the test in this bug description). Working code fragment: .section __TEXT,__text,regular,pure_instructions
.align 4, 0x90
__ZN10light_fuse4anon7expr_fn2anE: ## @_ZN10light_fuse4anon7expr_fn2anE
.cfi_startproc
## BB#0: ## %function top level
subq $56, %rsp
Ltmp12:
.cfi_def_cfa_offset 64
movabsq $0, %rax
leaq 40(%rsp), %rsi
movq 32(%rdi), %rdi
movq (%rdi), %rcx
movq %rcx, 40(%rsp)
movq 8(%rdi), %rcx
movq %rcx, 48(%rsp)
movq %rax, %rdi
callq __ZN20_$SP$bomb.$x27static9glue_take19h9f15e2dd62f678e4arE
leaq 32(%rsp), %rdi
## implicit-def: RSI
movq 48(%rsp), %rax
movq 40(%rsp), %rcx
movq 8(%rcx), %rcx
movq %rcx, 8(%rsp) ## 8-byte Spill
movq %rax, (%rsp) ## 8-byte Spill
callq __ZN9Ident_new16h4688b2c57373e544v0.0E
leaq 32(%rsp), %rsi
movq (%rsp), %rdi ## 8-byte Reload
movq 8(%rsp), %rax ## 8-byte Reload
callq *%rax Broken code fragment .section __TEXT,__text,regular,pure_instructions
.align 4, 0x90
__ZN10light_fuse4anon7expr_fn2anE: ## @_ZN10light_fuse4anon7expr_fn2anE
.cfi_startproc
.cfi_personality 155, _upcall_rust_personality
Leh_func_begin5:
.cfi_lsda 16, Lexception5
## BB#0: ## %function top level
subq $88, %rsp
Ltmp15:
.cfi_def_cfa_offset 96
movq 32(%rdi), %rdi
vmovups (%rdi), %xmm0
vmovaps %xmm0, 64(%rsp)
xorl %eax, %eax
movl %eax, %edi
leaq 64(%rsp), %rsi
callq __ZN20_$SP$bomb.$x27static9glue_take19h9f15e2dd62f678e4arE
movq 64(%rsp), %rsi
movq 72(%rsp), %rdi
movq 8(%rsi), %rsi
Ltmp11:
leaq 56(%rsp), %rcx
movq %rdi, 32(%rsp) ## 8-byte Spill
movq %rcx, %rdi
## implicit-def: RCX
movq %rsi, 24(%rsp) ## 8-byte Spill
movq %rcx, %rsi
callq __ZN9Ident_new16h4688b2c57373e544v0.0E
Ltmp12:
jmp LBB5_1
LBB5_1: ## %normal return
leaq 56(%rsp), %rsi
movq 32(%rsp), %rdi ## 8-byte Reload
movq 16(%rsp), %rax ## 8-byte Reload
callq *%rax Look at the spill and reload instructions above: In the working fragment, (How much do you want to bet that this is some code in the implementation of the LLVM invoke instruction that is doing an incorrect arithmetic calculation...) |
@pnkfelix, I just updated LLVM last night, would you mind trying that to see if this problem is fixed now? Just in the rare case that they caught this so far :) |
@alexcrichton I'll do you one better: I grabbed a more recent LLVM and built a newer Problem still reproduces with the latest version I can build. So I'll probably look into filing an LLVM bug; I'll probably venture onto their chat room soon. Most recently tested LLVM version (which still has the problem):
|
Ah well, one can always hope at least. Thanks for checking though! |
At this point I have filed a bug against LLVM, here: Not much else we can do right now except (1.) stop using invoke, or (2.) fix the LLVM problem ourselves. |
The code in the initial report now works just fine, flagging as needstest |
Probably related to #9127 (or at least the stack traces look similar to me):
Update: Here is a isolated test case (importantly, it does not depend on pulling in
libsyntax
):The text was updated successfully, but these errors were encountered: