Skip to content

Commit 5ab6aef

Browse files
committed
crash is a longjmp
1 parent 3c7fcfa commit 5ab6aef

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

crates/byondapi-macros/src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,11 @@ pub fn bind(attr: TokenStream, item: TokenStream) -> TokenStream {
169169
)
170170
}
171171
,&[error_string]).unwrap();
172+
::byondapi::value::ByondValue::null()
172173
}
173174
} else {
174175
quote! {
175-
::byondapi::runtime::byond_runtime(error_string);
176+
::byondapi::runtime::byond_runtime(error_string)
176177
}
177178
};
178179

@@ -184,8 +185,8 @@ pub fn bind(attr: TokenStream, item: TokenStream) -> TokenStream {
184185
Ok(val) => val,
185186
Err(e) => {
186187
let error_string = ::std::format!("{e:?}");
188+
::std::mem::drop(e);
187189
#crash_syntax
188-
::byondapi::value::ByondValue::null()
189190
}
190191
}
191192

@@ -324,10 +325,11 @@ pub fn bind_raw_args(attr: TokenStream, item: TokenStream) -> TokenStream {
324325
)
325326
}
326327
,&[error_string]).unwrap();
328+
::byondapi::value::ByondValue::null()
327329
}
328330
} else {
329331
quote! {
330-
::byondapi::runtime::byond_runtime(error_string);
332+
::byondapi::runtime::byond_runtime(error_string)
331333
}
332334
};
333335

@@ -339,8 +341,8 @@ pub fn bind_raw_args(attr: TokenStream, item: TokenStream) -> TokenStream {
339341
Ok(val) => val,
340342
Err(e) => {
341343
let error_string = ::std::format!("{e:?}");
344+
::std::mem::drop(e);
342345
#crash_syntax
343-
::byondapi::value::ByondValue::null()
344346
}
345347
}
346348
}

crates/byondapi-rs/src/runtime.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
use crate::static_global::byond;
22
use std::ffi::CString;
33

4-
pub fn byond_runtime<S: Into<Vec<u8>>>(message: S) {
4+
/// Immediately returns a runtime from this context
5+
///
6+
/// # WARNING, THIS WILL NOT CALL DROP ON THINGS, YOU MUST DROP EVERYTHING BEFORE YOU CALL THIS FUNCTION
7+
pub unsafe fn byond_runtime<S: Into<Vec<u8>>>(message: S) -> ! {
58
let c_str = CString::new(message.into()).unwrap();
6-
unsafe { byond().Byond_CRASH(c_str.as_ptr()) }
9+
unsafe { byond().Byond_CRASH(c_str.as_ptr()) };
10+
panic!()
711
}

0 commit comments

Comments
 (0)