Skip to content

Using Chan from a thread created from a c library crashes after sometime #12391

Closed
@arturoc

Description

@arturoc

Reporting this here after asking in IRC

something like this:

spawn(proc(){    
    let (port,chan): (comm::Port<Message>, comm::Chan<Message>) = comm::Chan::new();
    let mut chan = ~chan;
    set_c_callback(c_callback, cast::transmute(&mut *chan));
});

extern "C" fn c_callback (data: *c_void){
    unsafe{
    let channel = data as *mut comm::Chan<Message>;
        (*channel).send(MessageType);
    }
}

where c_callback is called from a thread created by the c library crashes the application after a while with:

fatal runtime error: assertion failed: !ptr.is_null()

Program received signal SIGILL, Illegal instruction.
[Switching to Thread 0x7fffd7fff700 (LWP 28971)]
0x0000000000483d4b in rt::util::abort::h66e24f48938afe6eMim::v0.10.pre ()
(gdb) bt
#0 0x0000000000483d4b in rt::util::abort::h66e24f48938afe6eMim::v0.10.pre ()
#1 0x00000000007b73d1 in rt::local_ptr::compiled::take::he8a5e3f0ec45f53amAs::v0.1 ()
#2 0x00000000007c7778 in comm::Chan$LT$T$GT$::send::hfedc51b572bd5818fot::v0.1 ()
...

previously SharedChan seemed to work without problem

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-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