[rust-dev] Met with a terrible fate

Benjamin Herr ben at 0x539.de
Wed Jul 2 16:39:19 PDT 2014


Hi!

Anything in the std lib that touches the runtime (task spawning and
concurrency stuff, i/o, probably `Gc<T>` and some things I'm forgetting)
will assert that it's being called from within a rust task, meaning it
can obtain a reference to the runtime object providing those services
from it.

As far as I know, your options are pretty much to try really hard to
avoid using that functionality in code called from C, or arrange for
everything that makes use of the runtime into to be wrapped in a call to
`native::start()` or `green::start()`, which start up and tear down a
runtime object to make it available to user code they run.

This isn't super satisfying so I hope someone proves me wrong and
provides a better option. I vaguely hope that in the long run there'll
be something you can call from all extern "C" functions like
`start_up_a_runtime_in_the_background_for_this_thread_if_necessary()`
that would make sure that subsequent code can use runtime services
without requiring C code to be significantly restructured (and ideally
also something more lightweight to catch task failure before it tries to
unwind through C code), but afaik we aren't there yet.

-benh


On Thu, 2014-07-03 at 00:07 +0200, Isak Andersson wrote:
> Hello!

> I have written a library in Rust that has some pub extern fv's in it
> so that they are callable from C. I wrote a C program to try calling
> these functions and I was met with the following message:
> 
> % ./test
> 
> You've met with a terrible fate, haven't you?
> 
> fatal runtime error: Could not unwind stack, error = 5
> zsh: illegal hardware instruction  ./test
> 
> 
> To begin with, nice reference!
> 
> 
> Second of all. How do I fix this, I am guessing that I need to start
> the rust runtime or something but I don't know how to do this, if
> someone could point me in the right direction that would be great!
> 
> 
> If you need more specific code examples of what I'm doing I can
> provide it it's just that I'm gonna sleep now and it doesn't seem like
> that's all too relevant. Also I did link to the libraries in the order
> it told me to.
> 
> Cheers!
> 
> 
> Isak Andersson
> 
> _______________________________________________
> Rust-dev mailing list
> Rust-dev at mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev




More information about the Rust-dev mailing list