Compilation with GCC 5.3.1 breaks bullet

Post Reply
Sinsemilla
Posts: 4
Joined: Sun Sep 08, 2013 4:45 pm

Compilation with GCC 5.3.1 breaks bullet

Post by Sinsemilla »

Hello,

Unfortunately, when bullet is compiled with GCC 5.3.1 some things seem to go wrong. Since bullet got compiled with this GCC my Application crashes
when i try to allocate the btDvbtBroadPhase. The line of code which is crashing looks like this:

Code: Select all

m_pBroadPhase = new btDvbtBroadPhase;
When the crash is happening i can see an error in the debugger-output of my application. It simply says that a memory corruption occured... I will post the stack trace
later, since at the moment i don't have access to this computer.

My system is a freshly installed Ubuntu MATE 16.04.
Before i compiled with GCC 4.8.x, (Linux Mint 17) which went fine.
Sinsemilla
Posts: 4
Joined: Sun Sep 08, 2013 4:45 pm

Re: Compilation with GCC 5.3.1 breaks bullet

Post by Sinsemilla »

Meanwhile i don't think that this is related to bullet after all. I just copy pasted the Hello World example from the wiki, and this works.
It seems that my application or some other lib it links with gets broken somehow by the newer gcc :cry:

Sorry for for wrong blame.
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: Compilation with GCC 5.3.1 breaks bullet

Post by benelot »

Mistakes happen to everyone. No problem! Just rename your thread to [solved] ....(by editing your first post and adding the tag to the original title).
Sinsemilla
Posts: 4
Joined: Sun Sep 08, 2013 4:45 pm

Re: Compilation with GCC 5.3.1 breaks bullet

Post by Sinsemilla »

After some testing there is unfortunately still a small chance that the cause lies somewhere in Bullet, altough i believe that it is more likely that the
problem lies in the Irrlicht library.

For the sake of completeness i am posting my experiences also here:

My Application is only crashing on the first line of code when it is built with GCC 5.3.1 and uses both Irrlicht 1.8.3 and bullet 2.83.7 which themselves are also built with this compiler. It works flawlessly when just one of both libraries is used.

If my application links to Irrlicht 1.8.3 without Bullet, everything seem to work fine. One can take the Hello world example and compile and link it flawlessly to an Irrlicht 1.8.3
library. The same applies vice versa, one can take the Bullet Hello world example and compile and link it flawlessly to the current Bullet library whith GCC 5.3.1.

The Problem occurs when the application which is built links to both libraries and includes the irrlicht.h header. It then dies on the first line with a segfault and the output window shows a low level message.

The code i am testing this with is the Hello world example from Bullet.

Code: Select all

#include <iostream>
 
#include <irrlicht.h> 
#include <btBulletDynamicsCommon.h>
 
int main (void)
{
        btBroadphaseInterface* broadphase = new btDbvtBroadphase();
 
        btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
        btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
 
        btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver;
 
        btDiscreteDynamicsWorld* dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);
 
        dynamicsWorld->setGravity(btVector3(0, -10, 0));
 
 
        btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0, 1, 0), 1);
 
        btCollisionShape* fallShape = new btSphereShape(1);
 
 
        btDefaultMotionState* groundMotionState = new btDefaultMotionState(btTransform(btQuaternion(0, 0, 0, 1), btVector3(0, -1, 0)));
        btRigidBody::btRigidBodyConstructionInfo
                groundRigidBodyCI(0, groundMotionState, groundShape, btVector3(0, 0, 0));
        btRigidBody* groundRigidBody = new btRigidBody(groundRigidBodyCI);
        dynamicsWorld->addRigidBody(groundRigidBody);
 
 
        btDefaultMotionState* fallMotionState =
                new btDefaultMotionState(btTransform(btQuaternion(0, 0, 0, 1), btVector3(0, 50, 0)));
        btScalar mass = 1;
        btVector3 fallInertia(0, 0, 0);
        fallShape->calculateLocalInertia(mass, fallInertia);
        btRigidBody::btRigidBodyConstructionInfo fallRigidBodyCI(mass, fallMotionState, fallShape, fallInertia);
        btRigidBody* fallRigidBody = new btRigidBody(fallRigidBodyCI);
        dynamicsWorld->addRigidBody(fallRigidBody);
 
 
        for (int i = 0; i < 300; i++) {
                dynamicsWorld->stepSimulation(1 / 60.f, 10);
 
                btTransform trans;
                fallRigidBody->getMotionState()->getWorldTransform(trans);
 
                std::cout << "sphere height: " << trans.getOrigin().getY() << std::endl;
        }
 
        dynamicsWorld->removeRigidBody(fallRigidBody);
        delete fallRigidBody->getMotionState();
        delete fallRigidBody;
 
        dynamicsWorld->removeRigidBody(groundRigidBody);
        delete groundRigidBody->getMotionState();
        delete groundRigidBody;
 
 
        delete fallShape;
 
        delete groundShape;
 
 
        delete dynamicsWorld;
        delete solver;
        delete collisionConfiguration;
        delete dispatcher;
        delete broadphase;
 
        return 0;
}
The Error message i receive when it crashes is the following:
malloc.c:2395: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.
Post Reply