Page 1 of 1

Crash in ~CcdPhysicsController on empty controller

Posted: Tue Sep 05, 2006 6:40 pm
by Dragonlord
For testing purpose I create a CcdPhysicsController without attaching it to a physics environment yet. Upon cleaning up ( "delete" ) I got a segmentation fault:

Code: Select all

(gdb) bt
#0  0xb6ed3023 in __gnu_cxx::__normal_iterator<TypedConstraint**, std::vector<TypedConstraint*, std::allocator<TypedConstraint*> > >::__normal_iterator ()
#1  0xb6ed23d9 in std::vector<TypedConstraint*, std::allocator<TypedConstraint*> >::begin ()
#2  0xb6ece7ef in CcdPhysicsEnvironment::removeCcdPhysicsController ()
#3  0xb6ecb9d4 in CcdPhysicsController::~CcdPhysicsController ()
Looking at the source code I noticed that there is no NULL-Check on line CcdPhysicsController:107

Code: Select all

	m_cci.m_physicsEnv->removeCcdPhysicsController(this);
Using the latest stable version from the homepage.

Posted: Tue Sep 05, 2006 10:48 pm
by Erwin Coumans
Thanks for the report. It was indeed assumed the pointer is filled in.
An assert/check will be added.

http://code.google.com/p/bullet/issues/ ... 8&can=2&q=

Posted: Wed Sep 06, 2006 11:43 am
by Dragonlord
Wow... off-topic.

Anyways. Is an assertion the right thing to do? Just asking as not attaching a controller to the environment doesn't sound to me like a logical error. I did simply add a check to call the remove only if the pointer is non-NULL as the rest of the destructor works fine.

- Pl?ss Roland

Posted: Wed Sep 06, 2006 4:59 pm
by SteveBaker
Yeah - I agree. If the package allows you to create something - then it has to give you a way to destroy it again.