From 02f2c70fc7e554d7d27ce58ff949cefc593b6bc2 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 5 Dec 2022 16:24:59 +0100 Subject: [PATCH] Fix double panic due to validation errors If the thread was already panicking, the `Drop` implementation for `Validation` could cause a double panic. This would cause the thread to abort without any useful output, which is the opposite of what this `Drop` implementation tried to achieve. --- crates/fj-kernel/src/services/validation.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/services/validation.rs b/crates/fj-kernel/src/services/validation.rs index a0db159ed..55aeda512 100644 --- a/crates/fj-kernel/src/services/validation.rs +++ b/crates/fj-kernel/src/services/validation.rs @@ -1,4 +1,4 @@ -use std::collections::BTreeMap; +use std::{collections::BTreeMap, thread}; use crate::{ objects::{BehindHandle, Object}, @@ -23,7 +23,9 @@ impl Drop for Validation { println!("{err}"); } - panic!(); + if !thread::panicking() { + panic!(); + } } } }