i get segfault on hello world application. but only if the line "dynamicsWorld = DiscreteDynamicsWorld()" is in there.

Bug #1018887 reported by Michael Rochester
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pybullet
Invalid
Undecided
Unassigned

Bug Description

I run the code and it always segfaults.
if I remove ALL the code EXCEPT dynamicsWorld = DiscreteDynamicsWorld() then the application still segfaults
if I remove dynamicsWorld = DiscreteDynamicsWorld() then the application will continue past the point of segfault and stop instead when dynamicsWorld is next refered to.

Revision history for this message
Jean-Paul Calderone (exarkun) wrote :

Hi Michael. Thanks for your interest in pybullet. Can you provide more information about how to reproduce this problem?

I have Ubuntu 11.10, Python 2.7, bullet 2.77. I can run each of the demos successfully, without crashes.

Revision history for this message
Michael Rochester (codeforger) wrote :

Hello Jean-Paul. Thanks for the quick reply.

I have Ubuntu 12.04, python 2.7, bullet 2.78.

I have hunted arround in bullet.pyx and added print commands like so:

        print "RigidBody constructor start"
        if motion is None:
            motion = DefaultMotionState()
        if shape is None:
            shape = BoxShape(Vector3(0.5, 0.5, 0.5))
        self.motion = motion
        self.shape = shape
        cdef btVector3 inertia = btVector3(0, 0, 0)
        # TODO This is a weak heuristic to avoid using calculateLocalInertia on
        # a shape that does not support it (and will probably SIGABRT the
        # process). To be really safe, it will probably be necessary to
        # explicitly list the shapes which cannot have their local inertia
        # calculated.
        if mass != 0.0:
            shape.thisptr.calculateLocalInertia(mass, inertia)

        cdef btRigidBodyConstructionInfo* info
        info = new btRigidBodyConstructionInfo(
            mass, self.motion.thisptr, self.shape.thisptr, inertia)
        print "foo"

        self.thisptr = new btRigidBody(info[0])

        print "bar"
        del info
        print "RigidBody constructor end"

to the __init__ of class RigidBody.

Now when i run helloworld.py the console output is:

/pybullet/demos$ python helloworld.py

RigidBody constructor start
foo
Segmentation fault (core dumped)

I can see that it is the "self.thisptr = new btRigidBody(info[0])" line (~line1201) that causes the segfault as "bar" is never printed.

This is the constructor that is being called from line 20 of helloworld.py

I know C++ and Python and so I can understand the .pyx, but I dont know the complexites of bindings so unfortunately cannot come up with a solution to this segfault.

Thanks, Michael.

Revision history for this message
Jean-Paul Calderone (exarkun) wrote :

Thanks for the follow-up. I wonder if allocation of the btRigidBodyConstructionInfo is failing. Can you also print the value of `info`?

Also, it might be productive if you could run the unit tests. You can do that with trial (preferred) or python-discover or just edit bullet/test_bullet.py to call unittest.main() at the end.

I'll try to get Bullet 2.78 to see if that makes any difference (but I'm not sure when I'll actually be able to get to that).

Revision history for this message
Michael Rochester (codeforger) wrote :

Thank you for your help so far, we have our heart set on bullet for our next project and so it would be very usefull for us to get pybullet working.

Unfortunately trying to do these things showed even more errors:

to try to print 'info' I tried:
print info
and got:
Cannot convert 'btRigidBodyConstructionInfo *' to Python object
when I tried to buit. I also tried print info[0] and got:
Cannot convert 'btRigidBodyConstructionInfo' to Python object
I tried with printf and cout hoping my C++skills would come in handy but neither worked.

I tried to run bullet/test_bullet.py and it cant get past the `from bullet import` line giving:
ImportError: cannot import name ACTIVE_TAG
I cannot see why this import would fail and so cannot persue this any further.

By any chance are you attending the EuroPython conference this week? If so we could meet during one of the coding sprints and we can discuss possible solutions.

Revision history for this message
Jean-Paul Calderone (exarkun) wrote :

I wish I could be at EuroPython this year, but no such luck. :(

I'm also stumped about why ACTIVE_TAG cannot be imported. I wonder if the version of Cython has anything to do with the different behavior. I have been using 0.14.1.

As far as the info check goes, I guess my Cython is a bit rusty. `print info == NULL` should report the same information as I was interested in - whether or not a structured was allocated successfully.

Also, I want to point out that pybullet is a very incomplete bullet wrapper. It provides the very basics, enough to do simple shapes and simple kinematics with them, but it's currently missing many of the other advanced features of bullet. I'd love to see more contributors on the project, but I can't commit to doing much more work myself any time soon.

Revision history for this message
Michael Rochester (codeforger) wrote :

HI!
    I know its been a long time since this bug was discussed but GOOD NEWS!

    Having returned to my attempts to use pyBullet having reinstalled my system, it turns out that my issue was simply not installing bullet correctly.

    So this bug is infact not a bug, simply my stupididty, sorry for the inconvenience I caused.

Sam Bull (dreamsorcerer)
Changed in pybullet:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.