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.