You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Hanging and undefined behavior in register_virtuals when overriding RigidDynamicBody3D's _integrate_forces for GDExtension class #651
I've noticed this when attempting to override _integrate_forces when extending RigidDynamicBody3D for a GDExtension. _physics_process, process, and _ready all execute without any issue, but the moment I attempt to uncomment the class's _integrate_forces, Godot hangs, displaying the opening splash screen and never actually loading the scene. Use of a debugger and print statements reveals that the overriding _integrate_forces isn't even called, and the hang occurs after _ready is executed.
Using the debugger reveals that the hang is occurring when register_virtuals is called in RigidDynamicBody3D, specifically in the following call stack:
RigidDynamicBody3D::register_virtuals
call_with_ptr_args (expanded from the BIND_VIRTUAL_METHOD macro)
Occasionally, this will crash with an abort signal instead of hanging, but I've been unable to nail down what will allow me to reproduce a crash. The hang always occurs when there's no crash, and will do so regardless of the content of _integrate_forces.
I suspect the issue is related to #630 since overriding any of the virtual functions that take basic types doesn't produce this behavior, and _integrate_forces has a single parameter of type PhysicsDirectBodyState3D*.
After some more investigation, I've observed that occasionally a SIGABRT will end up being raised within Object::get_instance_binding in the first two lines. When _integrate_forces is commented out, the program runs as expected; when it's left in, the error reappears, with no compile-time errors in either case.
Setting a message tracepoint and print statements at the start and end of this function reveals that this function is actually being called twice but not actually finishing, and is being called from PhysicsBody3D's attempt to call the virtual _integrate_forces. It seems that this behavior itself might be part of the issue, as it's attempting to register the virtual functions while calling them, it seems.
Within the BIND_VIRTUAL_METHOD's expansion that calls `` is where the error appears to be raised, on the second call.
When debugging with GDB, the following error message is produced from the command line itself is sometimes produced:
Getting a call stack is proving difficult, however, as usually the program will simply hang as noted in the previous comment, and only occasionally produce the above message and crash outright. This leads me to suspect that something - perhaps the _instance_binding_mutex - is in an undefined state.
changed the title [-]Hanging in register_virtuals when overriding RigidDynamicBody3D's _integrate_forces for GDExtension class[/-][+]Hanging and undefined behavior in register_virtuals when overriding RigidDynamicBody3D's _integrate_forces for GDExtension class[/+]on Nov 17, 2021
Activity
nwroyer commentedon Nov 17, 2021
After some more investigation, I've observed that occasionally a
SIGABRTwill end up being raised withinObject::get_instance_bindingin the first two lines. When_integrate_forcesis commented out, the program runs as expected; when it's left in, the error reappears, with no compile-time errors in either case.The error is being raised in the line labeled 3 above.
Further exploration with GDB indicates that
RigidDynamicBody3D::register_virtualsis as follows:Setting a message tracepoint and print statements at the start and end of this function reveals that this function is actually being called twice but not actually finishing, and is being called from
PhysicsBody3D's attempt to call the virtual_integrate_forces. It seems that this behavior itself might be part of the issue, as it's attempting to register the virtual functions while calling them, it seems.Within the
BIND_VIRTUAL_METHOD's expansion that calls `` is where the error appears to be raised, on the second call.When debugging with GDB, the following error message is produced from the command line itself is sometimes produced:
godot.linuxbsd.tools.64: tpp.c:82: __pthread_tpp_change_priority: Assertionnew_prio == -1 || (new_prio >= fifo_min_prio && new_prio <= fifo_max_prio)' failed.`Getting a call stack is proving difficult, however, as usually the program will simply hang as noted in the previous comment, and only occasionally produce the above message and crash outright. This leads me to suspect that something - perhaps the
_instance_binding_mutex- is in an undefined state.[-]Hanging in register_virtuals when overriding RigidDynamicBody3D's _integrate_forces for GDExtension class[/-][+]Hanging and undefined behavior in register_virtuals when overriding RigidDynamicBody3D's _integrate_forces for GDExtension class[/+]