emk / abort_on_panic-rs Goto Github PK
View Code? Open in Web Editor NEWRust library to intercept panic! from unsafe locations and abort the process (for use with C FFI callbacks)
License: Creative Commons Zero v1.0 Universal
Rust library to intercept panic! from unsafe locations and abort the process (for use with C FFI callbacks)
License: Creative Commons Zero v1.0 Universal
The README states
This code is placed into the public domain under the terms described by the Unlicense.
but the license key in the toml file says CC0. Did 6a2e302 just forget to update the README?
Program received signal SIGILL, Illegal instruction.
0x00007ffff6a64f6d in util::abort::h02951b1e75008cc1HAa () from ./testmodule.so
(gdb) bt
#0 0x00007ffff6a64f6d in util::abort::h02951b1e75008cc1HAa () from ./testmodule.so
#1 0x00007ffff69d9899 in local_ptr::compiled::take::h14452098448178968240 () from ./testmodule.so
#2 0x00007ffff6a30697 in task::failing::hbfb6b409badfcd086tp () from ./testmodule.so
#3 0x00007ffff69ca781 in abort_on_panic::PanicGuard.Drop::drop (self=0x7fffffffded8) at src/lib.rs:49
#4 0x00007ffff69c4ad6 in abort_on_panic..PanicGuard::glue_drop.1623::h9a0c7ff411355a98 () from ./testmodule.so
#5 0x00007ffff69c4a6c in testmodule::inittestmodule () at <abort_on_panic macros>:13
#6 0x00007ffff69c47fe in inittestmodule () from ./testmodule.so
#7 0x000000000056e0b9 in _PyImport_LoadDynamicModule () at ../Python/importdl.c:53
This occurs when a python extension module written in Rust is imported into the normal python interpreter.
abort_on_panic works as expected when the python interpreter is hosted by a Rust program.
It's debatable whether this is a bug in task::failing()
or in abort_on_panic, but there's an easy workaround:
Replace the failing()
call with rustrt::local::Local::exists(None::<Task>) && failing()
std::io::stderr
panics if stderr cannot be accessed because the process is shutting down, therefore the panic guard does not do its job (on the other hand, it could be argued that it does work since it initiates a double panic that aborts the process). I'm not sure there is any solution.
struct S;
impl Drop for S {
fn drop(&mut self) {
abort_on_panic! {
// do nothing
}
}
}
fn main() {
let s = S;
panic!("Error!")
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.