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

translating statics/consts segfaults LLVM if order is wrong #29884

Closed
nikomatsakis opened this issue Nov 17, 2015 · 11 comments
Closed

translating statics/consts segfaults LLVM if order is wrong #29884

nikomatsakis opened this issue Nov 17, 2015 · 11 comments
Labels
A-codegen Area: Code generation I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nikomatsakis
Copy link
Contributor

This test case (a permutation of const-autoderef.rs) causes rustc to segfault (somewhere in LLVM):

static B: u8 = (&A)[0];
static A: [u8; 1] = ['h' as u8];
static D: u8 = (&C)[0];
static C: &'static &'static &'static &'static [u8; 1] = & & & &A;

pub fn main() {
    assert_eq!(B, A[0]);
    assert_eq!(D, A[0]);
}

Uncovered while working on separating items from HIR, since the new visitors can sometimes visit items in different orders (unless you force them to do otherwise).

@nikomatsakis nikomatsakis added I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-codegen Area: Code generation labels Nov 17, 2015
@nikomatsakis
Copy link
Contributor Author

I believe the cause of this is #26630.

@nikomatsakis
Copy link
Contributor Author

cc @eefriedman -- this is triggered by recursive statics (see also some notes on #29719, if you haven't already)

@arielb1
Copy link
Contributor

arielb1 commented Nov 17, 2015

duplicate of #28324 (or pseudo-duplicate - the issue was intended to capture the "actually linkable" case too).

@nikomatsakis
Copy link
Contributor Author

@arielb1 ah, yes, I remember this issue. And there is a legit question also of whether we should support the kind of derefs etc that are evident here vs having people create intermediate statics. I personally am not terribly fond of that, since the value of a static is not necessarily fixed over the course of an execution.

@nagisa
Copy link
Member

nagisa commented Nov 17, 2015

Reminder, that LLVM asserts turn into undefined behaviour (I believe?) when built in release mode. Probably would be good to compile a debug LLVM to see what’s the assert?

@arielb1
Copy link
Contributor

arielb1 commented Nov 18, 2015

@nagisa

The issue is known - we are attempting to dereference a static that is not defined.

@eefriedman
Copy link
Contributor

This is fixed.

@nikomatsakis
Copy link
Contributor Author

The original test case, indeed, does not seem to compile.

@nagisa
Copy link
Member

nagisa commented Jan 17, 2017

Shouldn’t we add a regression test or something?

@nikomatsakis
Copy link
Contributor Author

@nagisa I was thinking that the test for #28324 (I presume there is one...) sufficed.

@nagisa
Copy link
Member

nagisa commented Jan 17, 2017

Ah hmm. Okay nevermind then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants