Crash in ~CcdPhysicsController on empty controller

User avatar
Dragonlord
Posts: 198
Joined: Mon Sep 04, 2006 5:31 pm
Location: Switzerland

Crash in ~CcdPhysicsController on empty controller

Post 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.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post 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=
User avatar
Dragonlord
Posts: 198
Joined: Mon Sep 04, 2006 5:31 pm
Location: Switzerland

Post 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
Last edited by Dragonlord on Wed Sep 06, 2006 5:40 pm, edited 1 time in total.
User avatar
SteveBaker
Posts: 127
Joined: Sun Aug 13, 2006 4:41 pm
Location: Cedar Hill, Texas

Post 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.