cocos-engine
cocos-engine copied to clipboard
Bullet Physics: memory access out of bounds
Cocos Creator version
3.8.5
System information
Windows 11
Issue description
There is a complete freeze of the engine and a bunch of errors at random times, and I could not understand the specific reasons, from my observations the bug is observed when there is a new collision with something, conditionally the player goes into the trigger. Also I used in the project Configurable constraint, PointToPointConstraint maybe it will help.
Relevant error log output
Uncaught RuntimeError: memory access out of bounds
at 001ca272:0x19291
at 001ca272:0x36c8c
at 001ca272:0x3875b
at 001ca272:0x38964
at 001ca272:0x68e46
at 001ca272:0x65ab9
at Object.DynamicsWorld_stepSimulation (bullet.release.wasm.js:10:32466)
at BulletWorld.step (bullet-world.ts:196:12)
at PhysicsSystem.postUpdate (physics-system.ts:367:39)
at Director.tick (director.ts:791:38)
Steps to reproduce
Complex scene with many colliders, Configurable constraint, PointToPointConstraint. Take the ball, throw it into the trigger, and then walk around the trigger, it may not work right away, you need to turn around sharply and crash in, you may need to restart a few times.
https://github.com/user-attachments/assets/471fb5da-6733-4710-91de-04614cf65d7e
Minimal reproduction project
Hi @GeTechG , could you try to provide a demo for reproducing the issue? Otherwise, according the exception stack, it's difficult to figure out. Thanks.
Hi @GeTechG , could you try to provide a demo for reproducing the issue? Otherwise, according the exception stack, it's difficult to figure out. Thanks.
I'll try to recreate a little later, last attempt didn't go well, since this bug I found in a commercial project I can't provide you with.
@dumganhar I made a minmal project, please take a look.
Great, I will try to figure out.
I would like to clarify that I found the source of the problem, the problem occurs after deleting a node with physics, as I understand there is an unsynchronization of the physics engine and cocos, because of which there is a reference to non-existent memory, I temporarily solved the problem by hiding objects instead of deleting actually so I realized that the problem is in the deletion.
That's a good catch. Recently, I don't have enough time to investigate this issue. Sorry about that it may be delayed.
@GeTechG Please refer to the modifications in this PR and remove the redundant PointToPointConstraint for the small node in the test cases.