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

lookup_item ICE when &'self fn deref'ed from separate compile unit #6919

Closed
pnkfelix opened this issue Jun 3, 2013 · 6 comments

Comments

@pnkfelix
Copy link
Member

commented Jun 3, 2013

Spawned off of #5446. (This is a significantly narrowed down version of the test case described there; the problem with conditions appears to arise from its use of 'self region parameters for borrowed function pointers.)

(This top version is newer and thus labelled as a variant. The "original narrowing" is at the bottom of the report.)

iss.rc (variant 3):

#[link(name="iss6919_3", vers="0.1")];

struct C<'self> {
    pub k: &'self fn(), // <-- necessary; bug seems to require &'self functions.
}

fn no_op() { }
pub static D : C<'static> = C {
    k: no_op
};

main.rs (variant 3):

extern mod iss ( name = "iss6919_3" );
fn main() {
    iss::D.k; // <-- this is just a deref.  (An invocation fails too, but its uglier to write and would distract.)
}

Transcript:

% rustc --lib iss.rc
warning: no debug symbols in executable (-arch x86_64)
% RUST_LOG=rustc=1,::rt::backtrace rustc -L . main.rs 
rust: task failed at 'lookup_item: id not found: 11', /Users/fklock/Dev/Mozilla/rust.git/src/librustc/metadata/decoder.rs:92
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
rust: task failed at 'explicit failure', /Users/fklock/Dev/Mozilla/rust.git/src/librustc/rustc.rc:400
rust: domain main @0x7fa35b808410 root task failed
% rustc --version
/Users/fklock/opt/rust-dbg-nopt/bin/rustc 0.6 (4f6285f 2013-06-02 22:31:36 -0700)
host: x86_64-apple-darwin
% 

Original narrowed version below (but one above is smaller).

iss.rc:

#[link(name="iss", vers="0.1")];

struct C<'self> {
    k: &'self fn(), // <-- necessary; bug seems to require &'self functions.
}

impl<'self> C<'self> {
    pub fn r(&self) { }
}

fn no_op() { }
pub static D : C<'static> = C {
    k: no_op
};

main.rs:

extern mod iss;
fn main() { iss::D.r(); }

Transcript:

% rustc --lib iss.rc
warning: no debug symbols in executable (-arch x86_64)
% RUST_LOG=rustc=1,::rt::backtrace rustc -L . main.rs 
rust: task failed at 'lookup_item: id not found: 20', /Users/fklock/Dev/Mozilla/rust.git/src/librustc/metadata/decoder.rs:92
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
rust: task failed at 'explicit failure', /Users/fklock/Dev/Mozilla/rust.git/src/librustc/rustc.rc:400
rust: domain main @0x7fe851808410 root task failed
% rustc --version
/Users/fklock/opt/rust-dbg-nopt/bin/rustc 0.6 (4f6285f 2013-06-02 22:31:36 -0700)
host: x86_64-apple-darwin
% 
@Blei

This comment has been minimized.

Copy link
Contributor

commented Jun 4, 2013

I spent some time debugging this and apparently if you mark no_op as pub, everything works! Investigating...

@Blei

This comment has been minimized.

Copy link
Contributor

commented Jun 4, 2013

The problem seems to be that there is no code in place to check that private functions are not "leaked" with the use of statics. This leads to the further minimized test program (variant 4, if you will):

iss.rc

#[link(name="iss6919_4", vers="0.1")];

fn no_op() { }
pub static k: extern "Rust" fn() = no_op;

main.rs

extern mod iss ( name = "iss6919_4" );
fn main() {
    iss::k;
}
@Blei

This comment has been minimized.

Copy link
Contributor

commented Jun 4, 2013

Ok, I think I know more or less what to do to find such private-but-leaked functions and how to export them. But the problem is: that probably makes them visible from outside the crate, which is probably not desirable. What now?

Blei added a commit to Blei/rust that referenced this issue Jun 5, 2013
@Blei

This comment has been minimized.

Copy link
Contributor

commented Jun 5, 2013

The following commit fixes the ICE, but also exports all private functions that are referenced using visible statics: Blei/rust@c96afd8.

@Blei

This comment has been minimized.

Copy link
Contributor

commented Jun 5, 2013

Hmm this commit also exports lots of other stuff it shouldn't... Sorry for the spam

@cmr

This comment has been minimized.

Copy link
Member

commented Jul 24, 2013

There is no longer an ICE with the reduced or original testcase. Needs test in testsuite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.