-
Notifications
You must be signed in to change notification settings - Fork 124
Description
When a Lua ph_button object is switched to an empty xr_logic section via its on_press handler, the associated reset_scheme callback will invoke self.object:play_cycle with self.st.anim as nil, terminating the program with a Lua error: C++ Exception popup.
This is the underlying cause of the X8 door crash in #369
Following some research, the underlying CScriptGameObject::play_cycle method is not called; luabind throws an exception before this can happen.
An explanation for this can be found in the luabind manual: As per the LUABIND_NO_ERROR_CHECKING section, overridden functions have their parameters type-checked before call in order to determine the target signature. This throws an exception on type mismatch, which is caught and propagated to our lua_error() handler.
This was a silent failure under the previous version of luabind, but propagates correctly following bf92f5c, resulting in a user-facing X8 door crash.
The surface problem is fixed by 0bd051a, but further issues remain:
ph_buttonshould perform a validity check on its animation and fail at construction time with a descriptive misconfiguration errorLUABIND_NO_ERROR_CHECKINGprevents luabind from typechecking the parameters of non-overridden C++ functions- This is inconsistent, and likely masks various script errors
- The proper solution is to disable the flag in release builds and fix the resulting script errors, as their scope is potentially quite broad
- Likely to touch on
vector/matrixmisuse and other common fail cases, possibly extending to variants of busyhands
- Likely to touch on
Here is the X8 door debugging script used to verify this bug:
x8_door_debug.zip
It adds printf tracing to the relevant xr_logic / ph_button functions, and was used in conjunction with C++ patches to the overloads of CScriptGameObject::play_cycle which added Msg calls to confirm that it was not invoked.