Skip to content

Syntax crates are broken on OSX Homebrew builds #12178

Closed
@sfackler

Description

@sfackler

A minimal-ish example:

#[feature(macro_registrar)];
#[crate_id = "procmacro"];
#[crate_type = "rlib"];
#[crate_type = "dylib"];

extern mod syntax;

use syntax::ast;
use syntax::ast::Name;
use syntax::codemap::{Span};
use syntax::ext::base;
use syntax::ext::base::{SyntaxExtension, BasicMacroExpander, NormalTT, ExtCtxt};
use syntax::parse::token;

#[macro_registrar]
pub fn macro_registrar(register: |Name, SyntaxExtension|) {
    register(token::intern("mymac"),
    NormalTT(~BasicMacroExpander {
        expander: expand_syntax_ext,
        span: None,
    },
    None));
}

pub fn expand_syntax_ext(_: &mut ExtCtxt,
                        sp: Span,
                        _: &[ast::TokenTree]) -> base::MacResult {
  println!("{:?}", sp);
  base::MacResult::dummy_expr()
}
#[feature(phase)];

#[phase(syntax)]
extern mod procmacro;

fn main() {
  mymac!(1 + 1);
}
try.rs:10:3: 10:8 error: macro undefined: 'mymac'
try.rs:10   mymac!(1 + 1);
            ^~~~~
error: aborting due to previous error
fish: Job 1, 'rustc try.rs -L .' terminated by signal SIGSEGV (Address boundary error)

Backtrace:

thread #2: tid = 0x1a5ec3, 0x00000001000a2243 libstd-966edb7e-0.10-pre.dylib`rt::task::__extensions__::run::anon::anon::expr_fn::aq + 211, stop reason = EXC_BAD_ACCESS (code=1, address=0x10e762470)
    frame #0: 0x00000001000a2243 libstd-966edb7e-0.10-pre.dylib`rt::task::__extensions__::run::anon::anon::expr_fn::aq + 211
    frame #1: 0x0000000103402620
    frame #2: 0x00000001000a215f libstd-966edb7e-0.10-pre.dylib`rt::task::__extensions__::run::anon::expr_fn::ap + 79
    frame #3: 0x00000001000a987c libstd-966edb7e-0.10-pre.dylib`rust_try + 12
    frame #4: 0x00000001000a20b1 libstd-966edb7e-0.10-pre.dylib`rt::task::Task::run::hdd180d0b0d7e46390gam::v0.10.pre + 81
    frame #5: 0x00000001005b9b5e libgreen-80d9e76a-0.10-pre.dylib`task::__extensions__::build_start_wrapper::anon::expr_fn::aP + 302

There are a couple of things that are weird here:

  • mymac isn't being registered properly. Maybe it's using a different interner than the rest of rustc?
  • The segfault is happening way outside of the expansion infrastructure. One possibility is that it's trying to call into the external crate somehow, but that's already been unloaded. Maybe the @-box annihilator?
  • This has cropped up in a couple of places, all on OSX, and all via rust installs built by Homebrew. Manually building and installing seems to fix the issue. The only nonstandard thing the Homebrew build does is symlinking all of the libraries and executables in place.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-syntaxextArea: Syntax extensionsI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions