{"action":"created","issue":{"url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/18864","repository_url":"https://api.github.com/repos/cocos2d/cocos2d-x","labels_url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/18864/labels{/name}","comments_url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/18864/comments","events_url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/18864/events","html_url":"https://github.com/cocos2d/cocos2d-x/issues/18864","id":327339689,"node_id":"MDU6SXNzdWUzMjczMzk2ODk=","number":18864,"title":"After first call to addPhysics3DConstraint(), app crashes on exit","user":{"login":"georgerbr","id":4930759,"node_id":"MDQ6VXNlcjQ5MzA3NTk=","avatar_url":"https://avatars2.githubusercontent.com/u/4930759?v=4","gravatar_id":"","url":"https://api.github.com/users/georgerbr","html_url":"https://github.com/georgerbr","followers_url":"https://api.github.com/users/georgerbr/followers","following_url":"https://api.github.com/users/georgerbr/following{/other_user}","gists_url":"https://api.github.com/users/georgerbr/gists{/gist_id}","starred_url":"https://api.github.com/users/georgerbr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/georgerbr/subscriptions","organizations_url":"https://api.github.com/users/georgerbr/orgs","repos_url":"https://api.github.com/users/georgerbr/repos","events_url":"https://api.github.com/users/georgerbr/events{/privacy}","received_events_url":"https://api.github.com/users/georgerbr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-05-29T14:13:36Z","updated_at":"2018-06-08T14:38:24Z","closed_at":null,"author_association":"NONE","body":"- cocos2d-x version: 3.17\r\n- devices test on: win32 desktop (Windows 8.1 64-bit)\r\n- developing environments\r\n   - VS version: VS2015\r\n\r\nSteps to Reproduce:\r\n\r\n1. Run Physics3D Test - Physics3D Constraint (it is the second test). It will call https://github.com/cocos2d/cocos2d-x/blob/18a6d8241d9a1290bfd6341ea6159877906d780a/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.cpp#L407\r\n2. Close the application\r\n3. Crash.\r\n"},"comment":{"url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/comments/395781355","html_url":"https://github.com/cocos2d/cocos2d-x/issues/18864#issuecomment-395781355","issue_url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/18864","id":395781355,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NTc4MTM1NQ==","user":{"login":"georgerbr","id":4930759,"node_id":"MDQ6VXNlcjQ5MzA3NTk=","avatar_url":"https://avatars2.githubusercontent.com/u/4930759?v=4","gravatar_id":"","url":"https://api.github.com/users/georgerbr","html_url":"https://github.com/georgerbr","followers_url":"https://api.github.com/users/georgerbr/followers","following_url":"https://api.github.com/users/georgerbr/following{/other_user}","gists_url":"https://api.github.com/users/georgerbr/gists{/gist_id}","starred_url":"https://api.github.com/users/georgerbr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/georgerbr/subscriptions","organizations_url":"https://api.github.com/users/georgerbr/orgs","repos_url":"https://api.github.com/users/georgerbr/repos","events_url":"https://api.github.com/users/georgerbr/events{/privacy}","received_events_url":"https://api.github.com/users/georgerbr/received_events","type":"User","site_admin":false},"created_at":"2018-06-08T14:38:24Z","updated_at":"2018-06-08T14:38:24Z","author_association":"NONE","body":"I investigated further, and found out that by the time `Physics3DWorld::~Physics3DWorld()` is called, `Physics3DWorld::addPhysics3DObject()` was never called and `physicsScene->getPhysics3DWorld()->_objects.size()`is `0` -- that is, no `Physics3DObject` was ever added to the `Physics3DWorld`.\r\n\r\nThe consequence is that when `removeAllPhysics3DConstraints()` and `removeAllPhysics3DObjects()` [are called](https://github.com/cocos2d/cocos2d-x/blob/18a6d8241d9a1290bfd6341ea6159877906d780a/cocos/physics3d/CCPhysics3DWorld.cpp#L49-L52), they have no work to do because `Physics3DWorld::_objects` is empty:\r\n\r\n```cpp\r\nPhysics3DWorld::~Physics3DWorld()\r\n{\r\n    removeAllPhysics3DConstraints();\r\n    removeAllPhysics3DObjects();\r\n```\r\n\r\nBut even though `Physics3DWorld::_objects` is empty, the `btRigidBody` object(s) still exist and the constraint knows it. It looks like there is a logic bug: the `Physics3DObject` object(s) that hold the `btRigidBody` object(s) must be added to the `Physics3DWorld` so that they can be properly disposed of by the time `Physics3DWorld::~Physics3DWorld()` is called, and the assert I referred to doesn't fire."}}
{"actor":{"display_login":"georgerbr"}}