forked from M-Labs/artiq
ksupport: raise RuntimeError on reraise with no inflight exception.
Fixes #1123.
This commit is contained in:
parent
2008d02f4d
commit
a74958f01f
|
@ -169,6 +169,9 @@ def fn_ValueError():
|
|||
def fn_ZeroDivisionError():
|
||||
return types.TExceptionConstructor(TException("ZeroDivisionError"))
|
||||
|
||||
def fn_RuntimeError():
|
||||
return types.TExceptionConstructor(TException("RuntimeError"))
|
||||
|
||||
def fn_range():
|
||||
return types.TBuiltinFunction("range")
|
||||
|
||||
|
|
|
@ -447,7 +447,7 @@ class CommKernel:
|
|||
self._write_string(function)
|
||||
else:
|
||||
exn_type = type(exn)
|
||||
if exn_type in (ZeroDivisionError, ValueError, IndexError) or \
|
||||
if exn_type in (ZeroDivisionError, ValueError, IndexError, RuntimeError) or \
|
||||
hasattr(exn, "artiq_builtin"):
|
||||
self._write_string("0:{}".format(exn_type.__name__))
|
||||
else:
|
||||
|
|
|
@ -10,6 +10,7 @@ from artiq.coredevice.runtime import source_loader
|
|||
ZeroDivisionError = builtins.ZeroDivisionError
|
||||
ValueError = builtins.ValueError
|
||||
IndexError = builtins.IndexError
|
||||
RuntimeError = builtins.RuntimeError
|
||||
|
||||
|
||||
class CoreException:
|
||||
|
|
|
@ -392,7 +392,7 @@ static mut INFLIGHT: ExceptionInfo = ExceptionInfo {
|
|||
private: [0; uw::unwinder_private_data_size],
|
||||
},
|
||||
exception: None,
|
||||
handled: false,
|
||||
handled: true,
|
||||
backtrace: [0; MAX_BACKTRACE_SIZE],
|
||||
backtrace_size: 0
|
||||
};
|
||||
|
@ -418,8 +418,22 @@ pub unsafe extern fn raise(exception: *const Exception) -> ! {
|
|||
#[export_name="__artiq_reraise"]
|
||||
#[unwind(allowed)]
|
||||
pub unsafe extern fn reraise() -> ! {
|
||||
use cslice::AsCSlice;
|
||||
|
||||
if INFLIGHT.handled {
|
||||
raise(&INFLIGHT.exception.unwrap())
|
||||
match INFLIGHT.exception {
|
||||
Some(ref exception) => raise(exception),
|
||||
None => raise(&Exception {
|
||||
name: "0:artiq.coredevice.exceptions.RuntimeError".as_c_slice(),
|
||||
file: file!().as_c_slice(),
|
||||
line: line!(),
|
||||
column: column!(),
|
||||
// https://github.com/rust-lang/rfcs/pull/1719
|
||||
function: "__artiq_reraise".as_c_slice(),
|
||||
message: "No active exception to reraise".as_c_slice(),
|
||||
param: [0, 0, 0]
|
||||
})
|
||||
}
|
||||
} else {
|
||||
uw::_Unwind_Resume(&mut INFLIGHT.uw_exception)
|
||||
}
|
||||
|
|
|
@ -68,13 +68,13 @@ macro_rules! raise {
|
|||
($name:expr, $message:expr, $param0:expr, $param1:expr, $param2:expr) => ({
|
||||
use cslice::AsCSlice;
|
||||
let exn = $crate::eh::Exception {
|
||||
name: concat!("0:artiq.coredevice.exceptions.", $name).as_bytes().as_c_slice(),
|
||||
file: file!().as_bytes().as_c_slice(),
|
||||
name: concat!("0:artiq.coredevice.exceptions.", $name).as_c_slice(),
|
||||
file: file!().as_c_slice(),
|
||||
line: line!(),
|
||||
column: column!(),
|
||||
// https://github.com/rust-lang/rfcs/pull/1719
|
||||
function: "(Rust function)".as_bytes().as_c_slice(),
|
||||
message: $message.as_bytes().as_c_slice(),
|
||||
function: "(Rust function)".as_c_slice(),
|
||||
message: $message.as_c_slice(),
|
||||
param: [$param0, $param1, $param2]
|
||||
};
|
||||
#[allow(unused_unsafe)]
|
||||
|
|
Loading…
Reference in New Issue