Don't catch Rust panics in userdata finalizer on drop

This commit is contained in:
Alex Orlenko 2021-08-06 11:14:16 +01:00
parent 1020315a9b
commit 1d7f105585
No known key found for this signature in database
GPG Key ID: 4C150C250863B96D
1 changed files with 4 additions and 5 deletions

View File

@ -450,11 +450,10 @@ pub unsafe fn init_userdata_metatable<T>(
}
pub unsafe extern "C" fn userdata_destructor<T>(state: *mut ffi::lua_State) -> c_int {
callback_error(state, |_| {
check_stack(state, 1)?;
// It's probably NOT a good idea to catch Rust panics in finalizer
// Lua 5.4 ignores it, other versions generates `LUA_ERRGCMM` without calling message handler
take_userdata::<T>(state);
Ok(0)
})
0
}
// In the context of a lua callback, this will call the given function and if the given function