Skip to content

Meeting a terrible fate when calling debug! macro from C #17559

Closed
@martinraison

Description

@martinraison

I have a C program using a rust library that calls the debug! macro. Here is the setup:

system: OS X Mavericks 10.9.4

bar.rs

#![feature(phase)]

#[phase(plugin, link)]
extern crate log;

#[no_mangle]
pub unsafe extern "C" fn test() {
    debug!("Hello");
}

bar.h

void test();

test.c

#include "bar.h"

int main(int argc, char *argv[]) {
    test();
}

I'm able to compile it using

rustc --crate-type staticlib bar.rs
gcc -Wall -o test test.c -L. -lbar

but it crashes at runtime:

$ ./test

You've met with a terrible fate, haven't you?

fatal runtime error:  assertion failed: queue != 0
[1]    42775 illegal hardware instruction  ./test

I don't think the problem is specific to the debug! macro, because I've seen the exact same error in other situations. However this is the simplest example I've found. Note that I've been able to run other C programs using Rust libraries successfully (for example if I replace debug! with println! in the example, then everything is fine).

Maybe I'm missing a step somewhere, but it looks like a bug to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions