Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"AssertionError: shape already added to space" #41

Closed
viblo opened this issue Oct 4, 2013 · 9 comments
Closed

"AssertionError: shape already added to space" #41

viblo opened this issue Oct 4, 2013 · 9 comments

Comments

@viblo
Copy link
Owner

viblo commented Oct 4, 2013

From alecatho...@gmail.com on August 30, 2010 12:56:30

What steps will reproduce the problem? 1. OSX +64-bit Python
2. Run pymunk unit tests. What is the expected output? What do you see instead? As discussed here: http://www.sweclockers.com/forum/10-programmering-och-digitalt-skapande/909659-python-osx-testa-mitt-fysiklib/ What version of the product are you using? On what operating system? Trunk, on OS-X Snow Leopard, with a 64-bit Python. Please provide any additional information below. I mainly filed this bug so that there will be a common location for people to track the issue.

Original issue: http://code.google.com/p/pymunk/issues/detail?id=42

@viblo
Copy link
Owner Author

viblo commented Oct 4, 2013

From vb%viblo...@gtempaccount.com on August 30, 2010 13:09:50

Short summary in for those who don't read swedish:
For some reason pymunk doesnt work on 64bit Python on OSX. The code can detect its 64 bit alright (with a check on how big a void pointer is), and it compiles chipmunk in -O3 -std=gnu99 -ffast-math -fPIC -DNDEBUG -arch x86_64 and everything looks fine when it loads it in. However, when doing something more advanced it fails with an error that look similar to what Ive got before when the struct alignment was wrong.

I would very much appreciate if someone could send me a patch or even just an idea on what exactly is the problem. I don't have a OSX machine to test on so it is very hard for me to debug it and I doubt I will be able to fix it for the next release unless I get some input :(

Status: Accepted
Owner: v...@viblo.se

@viblo
Copy link
Owner Author

viblo commented Oct 4, 2013

From alecatho...@gmail.com on August 30, 2010 16:46:42

I just checked out the source to start testing, ran "python setup.py build_chipmunk", and the tests all worked...

Previously, I was using the chipmunk build from Homebrew ( http://github.com/mxcl/homebrew ). This builds chipmunk from trunk but I haven't been able to figure out how to make the default chipmunk build show the actual gcc command line. The most it does show is this:

CFLAGS: -O3 -march=core2 -msse4.1 -w -pipe
CXXFLAGS: -O3 -march=core2 -msse4.1 -w -pipe
CPPFLAGS: -isystem /Users/aat/Homebrew/include
LDFLAGS: -L/Users/aat/Homebrew/lib

Whereas the pymunk build_chipmunk command uses:

cc -O3 -std=gnu99 -ffast-math -fPIC -DNDEBUG -arch i386 -arch x86_64 -Ichipmunk_src/include -c chipmunk_src/chipmunk.c -o chipmunk_src/chipmunk.o
...
cc -dynamiclib -arch i386 -arch x86_64 chipmunk_src/chipmunk.o chipmunk_src/cpArbiter.o chipmunk_src/cpArray.o chipmunk_src/cpBB.o chipmunk_src/cpBody.o chipmunk_src/cpCollision.o chipmunk_src/cpHashSet.o chipmunk_src/cpPolyShape.o chipmunk_src/cpShape.o chipmunk_src/cpSpace.o chipmunk_src/cpSpaceHash.o chipmunk_src/cpVect.o chipmunk_src/constraints/cpConstraint.o chipmunk_src/constraints/cpDampedRotarySpring.o chipmunk_src/constraints/cpDampedSpring.o chipmunk_src/constraints/cpGearJoint.o chipmunk_src/constraints/cpGrooveJoint.o chipmunk_src/constraints/cpPinJoint.o chipmunk_src/constraints/cpPivotJoint.o chipmunk_src/constraints/cpRatchetJoint.o chipmunk_src/constraints/cpRotaryLimitJoint.o chipmunk_src/constraints/cpSimpleMotor.o chipmunk_src/constraints/cpSlideJoint.o -o pymunk/libchipmunk.dylib

So it could be as simple as a mismatch in -arch, or it could be the different versions of chipmunk, or ...

So...in summary, I guess the "solution" for this is to always use build_chipmunk.

@viblo
Copy link
Owner Author

viblo commented Oct 4, 2013

From vb%viblo...@gtempaccount.com on August 31, 2010 03:46:24

Oh, so you say that it works just fine when you run it on a 64bit python on osx? That would be great! If that's the case maybe I can close this issue?

However, in the thread at sweclockers I did one version when pymunk only compiled it in 64bit on 64bit python, and 'You' reported that it didn't work using build_chipmunk.. It was some time ago but I don't remember any special fixes made to the compile or library load code after that.

@viblo
Copy link
Owner Author

viblo commented Oct 4, 2013

From nta...@gmail.com on September 28, 2010 12:01:47

Hmmm, I might have the same issue here. OS X Snow Leopard, 64-bit, but as I want to use chipmunk within Nodebox (which is a 32-bit application), I had to compile chipmunk as a 32-bit shared library:

$ file /usr/local/lib/libchipmunk.dylib
/usr/local/lib/libchipmunk.dylib: Mac-O dynamically linked shared library i386

However, when I run the unit tests for pymunk, I get quite a few exceptions similar to this:

ERROR: testSegmentQueries (tests.unittests.UnitTestSpace)

Traceback (most recent call last):
File "/Users/ntamas/Development/ThirdParty/pymunk-1.0.0/tests/unittests.py", line 110, in setUp
self.s.add(self.s1,self.s2)
File "/Users/ntamas/Development/ThirdParty/pymunk-1.0.0/pymunk/init.py", line 160, in add
self._add_shape(o)
File "/Users/ntamas/Development/ThirdParty/pymunk-1.0.0/pymunk/init.py", line 205, in _add_shape
assert shape._hashid not in self._shapes, "shape already added to space"
AssertionError: shape already added to space

The last exception is this:

FAIL: testShape (tests.unittests.UnitTestShape)

Traceback (most recent call last):
File "/Users/ntamas/Development/ThirdParty/pymunk-1.0.0/tests/unittests.py", line 86, in testShape
self.assertFalse( c.point_query((0,0)) )
AssertionError

I've just downloaded pymunk-1.0.0 again and recompiled everything, but it seems to be the same. Can you please help me with this?

FYI, when I compiled chipmunk (version 5.3.1), I simply downloaded the source code, then I did the following:

mkdir build
cd build
cmake ..
ccmake .

edited CMAKE_C_FLAGS and CMAKE_CXX_FLAGS to include -m32; they were empty before

make
cp src/libchipmunk*dylib /usr/local/lib

@viblo
Copy link
Owner Author

viblo commented Oct 4, 2013

From nta...@gmail.com on September 28, 2010 12:23:48

Hang on, it seems to work if I use the exact same version of chipmunk that is packaged with pymunk. Sorry for the false alarm.

@viblo
Copy link
Owner Author

viblo commented Oct 4, 2013

From vb%viblo...@gtempaccount.com on September 29, 2010 04:43:49

Great that you got it to work! When you say that you use the exact same version of chipmunk that is included in pymunk do you mean that you built it with setup.py build_chipmunk, or that you downloaded the same svn-version from the chipmunk repo?

@viblo
Copy link
Owner Author

viblo commented Oct 4, 2013

From nta...@gmail.com on September 29, 2010 04:45:40

I built it with setup.py build_chipmunk; I can try it using the SVN version this evening.

@viblo
Copy link
Owner Author

viblo commented Oct 4, 2013

From nta...@gmail.com on September 29, 2010 14:10:29

Just checked, it works with the SVN version as well. So the bottom line for others seeing the same test failures is that one has to use the exact same version of chipmunk, not the most recent one.

@viblo
Copy link
Owner Author

viblo commented Oct 4, 2013

From v...@viblo.se on August 28, 2011 09:40:26

Change this to done as there hasn't been any comments in almost a year and last report said it was working.

Status: Fixed

@viblo viblo closed this as completed Oct 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant