A panic solidcore's guard catches reaches the engine as EngineError::Internal
smlib's run() catches a solidcore panic and replaces the kernel (kept: the app does not die natively), returning Error::Internal; the kernel turned it into KernelError::Failed and the engine into Other, so hostile_params_never_panic and the fuzzer no longer saw kernel panics. Now the kernel's wrapper errors go through KernelError::smlib, which keeps Internal; a body the wrapper could not take because of a panic is Internal too. A feature whose evaluation hit it records the result as internal (not cached: the kernel was replaced), and the command that made it, or any command whose kernel call returns it, fails with EngineError::Internal under its own id. Crash reports mark a panic inside a solidcore call recovered (kernel::guarded), and the crash test's kernel mode panics inside a solidcore call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ
This commit is contained in:
@@ -131,9 +131,7 @@ fn crash_test(_: &mut Session, p: &Value) -> Result<Value> {
|
||||
match str_(p, "mode") {
|
||||
Some("panic") => std::panic::panic_any(String::from("crash test: an internal error in a command")),
|
||||
Some("kernel") => {
|
||||
solidcraft_kernel::guard("crash test", || -> solidcraft_kernel::Result<()> {
|
||||
std::panic::panic_any(String::from("an internal error in the kernel"))
|
||||
})?;
|
||||
solidcraft_kernel::crash_test()?;
|
||||
Err(EngineError::Other("crash test: the kernel error was not caught".into()))
|
||||
}
|
||||
Some("abort") => std::process::abort(),
|
||||
|
||||
@@ -826,8 +826,10 @@ fn add_feature_in(s: &mut Session, p: &Value, kind: FeatureKind, world: bool) ->
|
||||
}
|
||||
}
|
||||
let r = s.model.result(id).cloned();
|
||||
if let Some(e) = r.as_ref().and_then(|r| r.error.clone()) {
|
||||
return Err(EngineError::Other(e));
|
||||
if let Some(r) = &r
|
||||
&& let Some(e) = r.error.clone()
|
||||
{
|
||||
return Err(EngineError::of_feature(r, e));
|
||||
}
|
||||
let st = s.model.state();
|
||||
let bodies: Vec<&str> = st.bodies.iter().map(|b| b.name.as_str()).collect();
|
||||
|
||||
@@ -84,7 +84,10 @@ pub enum EngineError {
|
||||
|
||||
impl From<solidcraft_doc::DocError> for EngineError {
|
||||
fn from(e: solidcraft_doc::DocError) -> Self {
|
||||
EngineError::Other(e.to_string())
|
||||
match e {
|
||||
solidcraft_doc::DocError::Kernel(e) => e.into(),
|
||||
e => EngineError::Other(e.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<solidcraft_sketch::SketchError> for EngineError {
|
||||
@@ -94,7 +97,19 @@ impl From<solidcraft_sketch::SketchError> for EngineError {
|
||||
}
|
||||
impl From<solidcraft_kernel::KernelError> for EngineError {
|
||||
fn from(e: solidcraft_kernel::KernelError) -> Self {
|
||||
EngineError::Other(e.to_string())
|
||||
match e {
|
||||
// A panic the kernel caught: internal, as one in the command would be. The command's id
|
||||
// is filled in where the command is run (`Session::execute`).
|
||||
solidcraft_kernel::KernelError::Internal(m) => EngineError::Internal(String::new(), m),
|
||||
e => EngineError::Other(e.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl EngineError {
|
||||
/// The error a failed feature's result reports: internal when the kernel caught a panic.
|
||||
pub(crate) fn of_feature(r: &solidcraft_doc::FeatureResult, error: String) -> EngineError {
|
||||
if r.internal { EngineError::Internal(String::new(), error) } else { EngineError::Other(error) }
|
||||
}
|
||||
}
|
||||
impl From<solidcraft_io::IoError> for EngineError {
|
||||
@@ -1648,6 +1663,11 @@ impl Session {
|
||||
Err(EngineError::Internal(spec.id.to_string(), msg))
|
||||
}
|
||||
};
|
||||
// The kernel's internal errors come up without the command's id.
|
||||
let r = r.map_err(|e| match e {
|
||||
EngineError::Internal(id, msg) if id.is_empty() => EngineError::Internal(spec.id.to_string(), msg),
|
||||
e => e,
|
||||
});
|
||||
// A value typed as `name = expression` defines the user parameter `name` (#4071), in the
|
||||
// same undo step; a refused definition fails the command, which leaves the design as it was.
|
||||
let r = match r {
|
||||
@@ -2174,8 +2194,10 @@ impl Session {
|
||||
{
|
||||
self.doc_mut().marker = Some(idx + 1);
|
||||
self.refresh();
|
||||
if let Some(e) = self.model.result(fid).and_then(|r| r.error.clone()) {
|
||||
return Err(EngineError::Other(e));
|
||||
if let Some(r) = self.model.result(fid)
|
||||
&& let Some(e) = r.error.clone()
|
||||
{
|
||||
return Err(EngineError::of_feature(r, e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user