Bullet 2.81 + Visual Studio 2012, init crash

137Cs
Posts: 5
Joined: Sun Nov 11, 2012 6:18 pm

Bullet 2.81 + Visual Studio 2012, init crash

Post by 137Cs »

Bullet 2.80 works fine. However, I just can't get 2.81 to work. This simple init code:

Code: Select all

PhysicsWorld::PhysicsWorld()
: broadphase(0), collisionConfiguration(0), dispatcher(0), solver(0), dynamicsWorld(0)
{
	collisionConfiguration = new btDefaultCollisionConfiguration();

	dispatcher = new btCollisionDispatcher(collisionConfiguration);

	broadphase = new btDbvtBroadphase();

	btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver;

	dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);
	dynamicsWorld->setGravity(btVector3(0, -9.82f, 0));
}
Crashes at

Code: Select all

dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);
With the call stack

Code: Select all

 	msvcr110d.dll!_heap_alloc_base(unsigned int size) Line 57	C
 	msvcr110d.dll!_heap_alloc_dbg_impl(unsigned int nSize, int nBlockUse, const char * szFileName, int nLine, int * errno_tmp) Line 431	C++
 	msvcr110d.dll!_nh_malloc_dbg_impl(unsigned int nSize, int nhFlag, int nBlockUse, const char * szFileName, int nLine, int * errno_tmp) Line 239	C++
 	msvcr110d.dll!_nh_malloc_dbg(unsigned int nSize, int nhFlag, int nBlockUse, const char * szFileName, int nLine) Line 302	C++
 	msvcr110d.dll!malloc(unsigned int nSize) Line 56	C++
 	BulletFly.exe!btAllocDefault(unsigned int size) Line 24	C++
 	BulletFly.exe!btAlignedAllocDefault(unsigned int size, int alignment) Line 70	C++
 	BulletFly.exe!btAlignedAllocInternal(unsigned int size, int alignment) Line 163	C++
 	BulletFly.exe!btDiscreteDynamicsWorld::btDiscreteDynamicsWorld(btDispatcher * dispatcher, btBroadphaseInterface * pairCache, btConstraintSolver * constraintSolver, btCollisionConfiguration * collisionConfiguration) Line 227	C++
 	BulletFly.exe!PhysicsWorld::PhysicsWorld() Line 14	C++
What am I doing wrong?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Bullet 2.81 + Visual Studio 2012, init crash

Post by Erwin Coumans »

Do the unmodified Bullet demos compile and run fine?

If so, it would help if you compare your own program with the demos.
137Cs
Posts: 5
Joined: Sun Nov 11, 2012 6:18 pm

Re: Bullet 2.81 + Visual Studio 2012, init crash

Post by 137Cs »

The demos work fine. The init code is literally the HelloWorld init code, but with changed names.
137Cs
Posts: 5
Joined: Sun Nov 11, 2012 6:18 pm

Re: Bullet 2.81 + Visual Studio 2012, init crash

Post by 137Cs »

Recreating my project from scratch and rebuilding Bullet seems to have fixed it. I still have no rational explanation as to what caused it, though.
Adriano
Posts: 6
Joined: Fri Mar 08, 2013 9:53 am

Re: Bullet 2.81 + Visual Studio 2012, init crash

Post by Adriano »

If you remove BT_DOUBLE_PRECISION from your project, you have to recompile the entire Bullet, removing it also from the main project (bulletCollision, BulletDynamics, ...), before you can execute your project.
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Bullet 2.81 + Visual Studio 2012, init crash

Post by Basroil »

Adriano wrote:If you remove BT_DOUBLE_PRECISION from your project, you have to recompile the entire Bullet, removing it also from the main project (bulletCollision, BulletDynamics, ...), before you can execute your project.
Also an issue if you mix and match MD and MT within the same project. A good reason to always use rebuild after major changes.