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

ICE in ensure_public #29161

Closed
nagisa opened this Issue Oct 19, 2015 · 7 comments

Comments

Projects
None yet
5 participants
@nagisa
Copy link
Contributor

nagisa commented Oct 19, 2015

error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', ../src/libcore/option.rs:365
stack backtrace:
   1:     0x7fd8bfe28940 - sys::backtrace::tracing::imp::write::he27ef2eb40e30753Plt
   2:     0x7fd8bfe2f215 - panicking::log_panic::_<closure>::closure.39316
   3:     0x7fd8bfe2ec85 - panicking::log_panic::h20a17353a34447751lx
   4:     0x7fd8bfdf3783 - sys_common::unwind::begin_unwind_inner::hf876a8bedc1a7d89gds
   5:     0x7fd8bfdf40e8 - sys_common::unwind::begin_unwind_fmt::h69a2566a09092307mcs
   6:     0x7fd8bfe26801 - rust_begin_unwind
   7:     0x7fd8bfe79a7f - panicking::panic_fmt::h4197e07a6c9f36b2dMK
   8:     0x7fd8bfe73fb8 - panicking::panic::h14dc0798a39fe65fKKK
   9:     0x7fd8bf09823a - _<impl>::ensure_public::hde035fa84af6435dh0a
  10:     0x7fd8bf099244 - _<impl>::check_path::_<closure>::_<closure>::closure.12246
  11:     0x7fd8bf098c88 - _<impl>::check_path::_<closure>::closure.12244
  12:     0x7fd8bf09895b - _<impl>::check_path::h708120903b3b4e28Kbb
  13:     0x7fd8bf099b9a - _<impl>::visit_path::hdfda786dba7d0ea3jtb
  14:     0x7fd8bf09aef5 - _<impl>::visit_expr::h2d55fa99aaddc54awkb
  15:     0x7fd8bf09ae93 - _<impl>::visit_expr::h2d55fa99aaddc54awkb
  16:     0x7fd8bf0995e5 - visit::walk_item::walk_item::h16273349179620707161
  17:     0x7fd8bf09fe85 - check_crate::ha75a8757309cbaacuXb
  18:     0x7fd8c02f80da - driver::phase_3_run_analysis_passes::_<closure>::closure.21793
  19:     0x7fd8c02debf1 - middle::ty::context::_<impl>::create_and_enter::create_and_enter::h13642880013250108432
  20:     0x7fd8c02da02a - driver::phase_3_run_analysis_passes::h18429705411053108892
  21:     0x7fd8c02b8b64 - driver::compile_input::h8be95b88a1576d993ba
  22:     0x7fd8c041304b - run_compiler::h83cbc3300765328cysc
  23:     0x7fd8c04108d6 - boxed::_<impl>::call_box::call_box::h17940959236498258992
  24:     0x7fd8c04101e4 - sys_common::unwind::try::try_fn::try_fn::h12133114510587347876
  25:     0x7fd8bfe26668 - __rust_try
  26:     0x7fd8bfe1adeb - sys_common::unwind::try::inner_try::hbe46f56ef602f07cO9r
  27:     0x7fd8c041037e - boxed::_<impl>::call_box::call_box::h2880662908038604228
  28:     0x7fd8bfe2dce3 - sys::thread::_<impl>::new::thread_start::h13325138c3b56c4cdEw
  29:     0x7fd8b94fa4a3 - start_thread
  30:     0x7fd8bfabb13c - clone
  31:                0x0 - <unknown>

Trying to make the test case now.

@huonw huonw added the I-ICE label Oct 19, 2015

@nagisa

This comment has been minimized.

Copy link
Contributor Author

nagisa commented Oct 19, 2015

mod a {
    struct A;

    impl Default for A {
        pub fn default() -> A {
            A;
        }
    }
}


fn main() {
    a::A::default();
}
@nagisa

This comment has been minimized.

Copy link
Contributor Author

nagisa commented Oct 19, 2015

Works on current beta. Does not work on current nightly.

@steveklabnik steveklabnik referenced this issue Oct 23, 2015

Closed

Add ICEs to Glacier #29249

171 of 200 tasks complete
@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Oct 27, 2015

triage: P-high

@nikomatsakis nikomatsakis self-assigned this Oct 27, 2015

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Oct 27, 2015

The unwrap seems to be from trying to get a def-id from a node-id that is not registered.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Oct 27, 2015

Problem seems to be that the def-id is not local to the current crate.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Oct 27, 2015

OK, the problem is that when doing the def-id conversion, I converted this code:

.. if id == source_did.unwrap_or(to_check).node ..

into this:

        let def_id = source_did.unwrap_or(to_check);
        debug!("ensure_public: def_id = {:?}", def_id);
        let node_id = self.tcx.map.as_local_node_id(def_id).unwrap();

In particular, I used an unwrap when converting to a local node-id because the original code accessed the node field without checking the crate, which is only really valid if the def-id is local. In other words, I blame the original commit :P

But I'm trying now to figure out what is SUPPOSED to happen here. I still don't quite understand the flow of this code. In particular I don't know what source_did represents or why it is external here.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Oct 27, 2015

Probably the right fix is just to keep the Option:

        let def_id = source_did.unwrap_or(to_check);
        debug!("ensure_public: def_id = {:?}", def_id);
        let node_id = self.tcx.map.as_local_node_id(def_id);
        let (err_span, err_msg) = if Some(id) == node_id {

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Oct 27, 2015

The `source_did` may not be local, so don't unwrap the
`as_local_node_id`, instead just compare against `Some(id)`.
Fixes rust-lang#29161.

alexcrichton added a commit to alexcrichton/rust that referenced this issue Oct 29, 2015

The `source_did` may not be local, so don't unwrap the
`as_local_node_id`, instead just compare against `Some(id)`.
Fixes rust-lang#29161.

arcnmx added a commit to arcnmx/rust that referenced this issue Nov 2, 2015

The `source_did` may not be local, so don't unwrap the
`as_local_node_id`, instead just compare against `Some(id)`.
Fixes rust-lang#29161.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.