[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
Chipmunk Physics • View topic - bug in cpSpaceSegmentQueryFirst

bug in cpSpaceSegmentQueryFirst

Discuss any Chipmunk bugs here.

bug in cpSpaceSegmentQueryFirst

Postby viblo » Fri Dec 25, 2009 3:36 pm

I think Ive found a bug in cpSpaceSegmentQueryFirst, it hangs sometimes depending on the start/end value.
For example, I made two calls to it in an empty space:
with start = (13,1) and end = (131.01,2) it works
with start = (0,0) and end = (131.01,0) hangs in what feels like an infinite loop

(I did the testing from python, but I don't think that should affect this problem)
http://www.pymunk.org - A python library built on top of Chipmunk to let you easily get cool 2d physics in your python game/app
viblo
 
Posts: 206
Joined: Tue Aug 21, 2007 3:12 pm

Re: bug in cpSpaceSegmentQueryFirst

Postby slembcke » Sun Dec 27, 2009 12:06 pm

I wasn't able to reproduce the issue. Did you change the spatial hash settings at all?
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: bug in cpSpaceSegmentQueryFirst

Postby viblo » Sun Dec 27, 2009 8:24 pm

Oh, I should have created a little c program to test it directly... But you know how it is, I like coding in python much more than in c ;)

Anyway, after I read your post I created a little test program in c and at the first I couldn't reproduce it either, but after a lot of printf-debugging in the chipmunk code I think Ive found both the problem and why it didn't show up for me first. (Anyone know of a better way than binary-search-with-printfs to debug inside a compiled chipmunk.dll loaded from python?)

The problem is that in the cpSpaceHashSegmentQuery function in cpSpaceHash.c the next_v variable can be NaN. When you compile with -ffast-math the if-statement in the while loop select one exec path, and when you compile without the other path. That is, next_v < next_h is true with -ffast-math, and false without -ffast-math.
http://www.pymunk.org - A python library built on top of Chipmunk to let you easily get cool 2d physics in your python game/app
viblo
 
Posts: 206
Joined: Tue Aug 21, 2007 3:12 pm

Re: bug in cpSpaceSegmentQueryFirst

Postby slembcke » Sun Dec 27, 2009 9:05 pm

That's weird. I've never actually ran into an issue where -ffast-math didn't produce the correct results anyway on the PPC and Intel OS X and Linux machines that I've run on.

As for debugging, I'd normally say to just use good old GDB, but I have no idea if that would work on Windows with DLLs and all.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: bug in cpSpaceSegmentQueryFirst

Postby viblo » Tue Dec 29, 2009 10:06 am

http://www.pymunk.org - A python library built on top of Chipmunk to let you easily get cool 2d physics in your python game/app
viblo
 
Posts: 206
Joined: Tue Aug 21, 2007 3:12 pm

Re: bug in cpSpaceSegmentQueryFirst

Postby slembcke » Tue Dec 29, 2009 11:47 am

Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: bug in cpSpaceSegmentQueryFirst

Postby slembcke » Tue Dec 29, 2009 12:02 pm

Ok. I added a fix to detect the 0*infinity to prevent ever getting a NaN. Now it works using -ffast-math and without on processors that at least handle infinite math nicely without it.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm


Return to Bugs

Who is online

Users browsing this forum: No registered users and 1 guest

cron