C::B Segmentation Fault

Buck1000
Posts: 5
Joined: Sun Dec 27, 2009 8:13 pm

C::B Segmentation Fault

Post by Buck1000 »

I originally posted this on the irrlicht forums, but since the issue revolves around a function from Bullet Physics, I may be able to get more help here =]

Not sure if this is the right section, but I've run into a weird bug here that I can't seem to get rid off. My project compiles and runs fine VC++ 2008, but now that I've switched over to C::B, I've run into several issues. First were the linker errors, but those were easy. Now, my program compiles fine, but generates a segmentation fault when it runs. It uses Bullet for physics, and the crash happens on the stepsimulation instruction. Specifically

Code: Select all

World->stepSimulation(TDeltaTime * 0.001f, 1); 
Like I said, it works fine in MSVC. Heres the call stack at the time of the crash -

Code: Select all

#0 004148B9   btDiscreteDynamicsWorld::removeCollisionObject(btCollisionObject*) () (F:/Libraries/irrlicht-1.6/include/irrAllocator.h:30) 
#1 00409BEB   UpdatePhysics(TDeltaTime=720, Physics=0x22ff10) (C:/Documents and Settings/Cris/Desktop/Aftermath/Aftermath/physics.cpp:60) 
#2 00406B27   main() (C:/Documents and Settings/Cris/Desktop/Aftermath/Aftermath/main.cpp:143) 
Can anyone help me fix this? I can post the source if needed, but its alot of files.


And then a later post in the same thread -

Well, I changed some of the compiler flags (removed all optimizations), but now the call to removeCollisionObject is pointing to IQ3Shader.h. I'm not using any quake3 maps in my game though. All models are (.obj). Could it be that I'm using a list that might be valid in MSVC, but not with MingW G++? Heres the code using the list, its right after the stepSimulation command -

Code: Select all

for(list<btRigidBody *>::Iterator Iterator = Physics->Objects.begin(); Iterator != Physics->Objects.end(); ++Iterator) 
{ 
   UpdateRender(*Iterator, Physics); 
}

And Physics->Objects is

Code: Select all

list<btRigidBody *> Objects; 
Any special compiler flags I need to set?

EDIT: Oh, and I know thats were it crashes because I set breakpoints in various spots and ran the debugger, and thats the line it always crashes on. I commented out the call to UpdatePhysics in main(), and it runs like gravy. The call looks like -

Code: Select all

u32 TimeStamp = timer->getTime(); 
DeltaTime = 0; 
while(device->run() && driver) 
{ 
   DeltaTime = timer->getTime() - TimeStamp; 
   TimeStamp = timer->getTime(); 
   UpdatePhysics(DeltaTime, &Physics);  //(Physics) being a structure I use to hold all the data for the physics functions.

Thanks =]
Buck1000
Posts: 5
Joined: Sun Dec 27, 2009 8:13 pm

Re: C::B Segmentation Fault

Post by Buck1000 »

Anyone?
RapchikProgrammer
Posts: 8
Joined: Tue Feb 10, 2009 5:52 am

Re: C::B Segmentation Fault

Post by RapchikProgrammer »

Im thinking you are doing something wrong when initializing the physics objects.. look in that code, there might be an uninitialized variable, that vs sets to 0 but cb doesnt..
Buck1000
Posts: 5
Joined: Sun Dec 27, 2009 8:13 pm

Re: C::B Segmentation Fault

Post by Buck1000 »

No, nothing. Been trying to fix this for weeks, it still crashes. Can someone here try compiling my code if I give it to them? I need it compiled under g++ on Windows. You need Irrlicht and Bullet. Anyone?