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

local_crate ICE #2804

Closed
jesse99 opened this issue Jul 5, 2012 · 6 comments
Closed

local_crate ICE #2804

jesse99 opened this issue Jul 5, 2012 · 6 comments
Labels
A-linkage Area: linking into static, shared libraries and binaries I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Milestone

Comments

@jesse99
Copy link
Contributor

jesse99 commented Jul 5, 2012

When trying to compile the code below I get the following with a rust from June 30:

bugs: rustc ice.rs
rust: task failed at 'Assertion did.crate != ast::local_crate failed', /Users/jessejones/Source/Third_Party/rust/src/rustc/middle/ty.rs:2736
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=0,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
rust: task failed at 'explicit failure', /Users/jessejones/Source/Third_Party/rust/src/rustc/driver/rustc.rs:258
rust: domain main @0x7fb5d2000010 root task failed
rust: task failed at 'killed', /Users/jessejones/Source/Third_Party/rust/src/libcore/task.rs:461

Here is the code:


// rustc ice.rs
use std;
import io;
import io::writer_util;
import std::map::hashmap;

enum object
{
    bool_value(bool),
    int_value(i64),
}

fn lookup(table: std::map::hashmap<str, std::json::json>, key: str, default: str) -> str
{
    alt table.find(key)
    {
        option::some(std::json::string(s))
        {
            *s
        }
        option::some(value)
        {
            #error["%s was expected to be a string but is a %?", key, value];
            default
        }
        option::none
        {
            default
        }
    }
}

fn add_interface(store: int, managed_ip: str, data: std::json::json) -> (str, object)
{
    alt data
    {
        std::json::dict(interface)
        {
            let name = lookup(interface, "ifDescr", "");
            let label = #fmt["%s-%s", managed_ip, name];

            (label, bool_value(false))
        }
        _
        {
            #error["Expected dict for %s interfaces but found %?", managed_ip, data];
            ("gnos:missing-interface", bool_value(true))
        }
    }
}

fn add_interfaces(store: int, managed_ip: str, device: std::map::hashmap<str, std::json::json>) -> [(str, object)]/~
{
    alt device["interfaces"]
    {
        std::json::list(interfaces)
        {
            vec::map(*interfaces)
            {|interface|
                add_interface(store, managed_ip, interface)
            }
        }
        _
        {
            #error["Expected list for %s interfaces but found %?", managed_ip, device["interfaces"]];
            []/~
        }
    }
}
@jesse99
Copy link
Contributor Author

jesse99 commented Jul 5, 2012

Here is a simpler repro:


// rustc --lib ice.rs
use std;
import std::map::hashmap;

fn add_interfaces(s: str, data: std::map::hashmap<str, std::json::json>)
{
    #error["Expected list for %s interfaces but found %?", s, data["interfaces"]];
}

@jesse99
Copy link
Contributor Author

jesse99 commented Jul 5, 2012

Note that there is no ICE if data.get("interfaces") is used instead.

@catamorphism
Copy link
Contributor

I'll check this out.

@ghost ghost assigned catamorphism Jul 5, 2012
@catamorphism
Copy link
Contributor

Minimized to:

use std;
import std::map::hashmap;

fn add_interfaces(managed_ip: str, device: std::map::hashmap<str, std::json::json>)  {
      #error["%s, %?", managed_ip, device["interfaces"]];
}

@catamorphism
Copy link
Contributor

Also, it compiles if I manually expand the macro, like:

use std;
import std::map::hashmap;

fn add_interfaces(managed_ip: str, device: std::map::hashmap<str, std::json::json>)  {
    log(error, #fmt("%s, %?", managed_ip, device["interfaces"]));
}

@catamorphism
Copy link
Contributor

Splendid bug. The issue was that there's an index expression (device["interfaces"]) inside a macro (#fmt). Index exprs have a hidden extra node ID -- the "callee ID" -- for esoteric typechecking purposes, which is implicitly the previous node ID before its own node ID. The macro-expansion code was breaking that invariant and using managed_ip's node ID as the callee ID for device["interfaces"]. I have a fix, but I'd rather just kill the entire hack with fire, which I will proceed to do.

jbclements added a commit to jbclements/rust that referenced this issue Apr 3, 2013
jbclements added a commit to jbclements/rust that referenced this issue Apr 4, 2013
jbclements added a commit to jbclements/rust that referenced this issue Apr 10, 2013
saethlin pushed a commit to saethlin/rust that referenced this issue Mar 16, 2023
celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Concrete playback seeks to generate unit tests in the original source
file. An intermediate temporary file is used to reduce the risk of
corrupting original source files. Once the temporary file has been
completely written to, it is to be atomically moved to replace the
source file. This can only be done on the same file system.

We now create the temporary file in the same source directory as the
original source file to ensure we are on the same file system. The
implementation uses NamedTempFile from the tempfile crate, which renders
our own tempfile implementation redundant.

Tested on Ubuntu 20.04 with /tmp on a different partition (where our
regression tests would previously fail).

Resolves: rust-lang#2705
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

No branches or pull requests

2 participants