NewtonTreeCollisionEndBuild crash

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

NewtonTreeCollisionEndBuild crash

Postby bmwop » Mon Oct 04, 2010 7:30 am

Hi!

the NewtonTreeCollisionEndBuild() crashes in 2.24 (it was okay in 2.09)

test code:
Code: Select all
  NewtonWorld *nWorld = NewtonCreate(/*NULL, NULL*/);
    NewtonSetThreadsCount(nWorld, 2);

    {
        NewtonWorldCriticalSectionLock(nWorld);
        NewtonCollision* collision = NewtonCreateTreeCollision(nWorld, roadID/*, NULL*/);
        FILE* f = fopen("last_road_points", "r");
        NewtonTreeCollisionBeginBuild(collision);

        bool canRead = true;
        float vArray[9];

        printf("read points\n");
        while (canRead)
        {
            for (int wi = 0; wi < 9 && canRead; wi++)
            {
                int ret = fscanf(f, "%f\n", &vArray[wi]);
                if (ret < 1) canRead = false;
            }
            if (canRead)
            {
                NewtonTreeCollisionAddFace(collision, 3, (float*)vArray, 3 * sizeof(float), 1);
            }
        }
        fclose(f);
        printf("collisionendbuild\n");
        NewtonTreeCollisionEndBuild(collision, 0);
        printf("collisionendbuild done\n");
    }

for the test the following file contains the test points:
http://bmw.homelinux.org/newton/last_road_points

Am i doing something wrong?
bmwop
 
Posts: 15
Joined: Tue Aug 11, 2009 6:54 am

Re: NewtonTreeCollisionEndBuild crash

Postby Julio Jerez » Mon Oct 04, 2010 8:31 am

why are you using a critical section?
critical section are meant to be used in callbacks.

and if you use it you are not closing the section, whi mean teh prgam will frezze or crash if it enter another section.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonTreeCollisionEndBuild crash

Postby bmwop » Mon Oct 04, 2010 8:48 am

I copied the code from the original place, so the CS is not needed here, but anyway it will crash, so it does not matter.

here is the backtrace from the gdb:
#0 0xb6c21d8c in memcpy () from /lib/libc.so.6
#1 0xb7bad0e8 in _ZN15InternalGeoUtilL12SortVerticesEPfiiiif () from ./lib/libNewton.so
#2 0xb7badcd5 in dgVertexListToIndexList () from ./lib/libNewton.so
#3 0xb7bc4ef1 in dgAABBPolygonSoup::Create () from ./lib/libNewton.so
#4 0xb7c4c0ec in dgCollisionBVH::EndBuild () from ./lib/libNewton.so
#5 0xb7cba854 in NewtonTreeCollisionEndBuild () from ./lib/libNewton.so
bmwop
 
Posts: 15
Joined: Tue Aug 11, 2009 6:54 am

Re: NewtonTreeCollisionEndBuild crash

Postby Julio Jerez » Mon Oct 04, 2010 9:37 am

Ok I pasted that code in the test demo, and you are correct it does crash.
Your mesh is one of those pathological arrays of points in which qsort algorithm result into a n O(n^2)
In 2.22 I replaced the standard qsort with a Template based sort that does not allocate memory
And is non recursive, this is much faster than the standard one.
but the stack pool is too small for pathological arrays.
The pool was set to 128 levels deep, but your mesh goes around 500+ deep.

I changed the stack pool to 1024, this is an extreme rare cituation that should never happen, so a stack of 1024 should be good for anything.

I fixed already, Get replacement library here
http://www.newtondynamics.com/downloads ... n-2.25.rar
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonTreeCollisionEndBuild crash

Postby bmwop » Mon Oct 04, 2010 2:00 pm

Thanks for the reply and the explanation. I checked that, and it was okay. (but my raycast car's tires behave strangely with this)
bmwop
 
Posts: 15
Joined: Tue Aug 11, 2009 6:54 am

Re: NewtonTreeCollisionEndBuild crash

Postby Julio Jerez » Mon Oct 04, 2010 2:06 pm

what do you mean that?
the fix did not change anything else. how was working before?

Is the debug display correct?

I see you are using libraries with .so extension. are you in Linux?
the fix in only in the PC build.
I am confused. how do you get a .so library?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonTreeCollisionEndBuild crash

Postby bmwop » Mon Oct 04, 2010 3:24 pm

Here are two videos, one from the old (good) newton:
http://bmw.homelinux.org/newton/good.avi

and the other from the new 2.25 (wrong) newton:
http://bmw.homelinux.org/newton/wrong.avi

This car is mostly build on the DGRaycastCar.
I am using both linux and windows (with gcc).
bmwop
 
Posts: 15
Joined: Tue Aug 11, 2009 6:54 am

Re: NewtonTreeCollisionEndBuild crash

Postby Julio Jerez » Mon Oct 04, 2010 3:50 pm

I can not see the videos it just play the audio, can you post it youtube or
better can you post and executable of the windows vertion?
Maybe something else is wrong
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonTreeCollisionEndBuild crash

Postby bmwop » Mon Oct 04, 2010 4:34 pm

the fraps uses a strange avi format to record video, i can play it with mplayer but cannot convert it, so i made a video with my mobile:
http://bmw.homelinux.org/newton/wrong.wmv
http://bmw.homelinux.org/newton/wrong.mov

it is only from the wrong case, the tires should move totally straight on the road.
bmwop
 
Posts: 15
Joined: Tue Aug 11, 2009 6:54 am

Re: NewtonTreeCollisionEndBuild crash

Postby Julio Jerez » Mon Oct 04, 2010 5:18 pm

It look like Raycast is boosted?
Are you using the joint librray from 2.25?, dot not use the library only the Newton libraries.

also can you make the video with the debug collision, jus to make sure the polygons are there?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonTreeCollisionEndBuild crash

Postby bmwop » Tue Oct 05, 2010 3:05 am

Julio Jerez wrote:It look like Raycast is boosted?
Are you using the joint librray from 2.25?, dot not use the library only the Newton libraries.

no, i am using some older with modifications, but i compiled it myself, so i don't use the jointlibrary.dll.

Julio Jerez wrote:also can you make the video with the debug collision, jus to make sure the polygons are there?

Do you mean the NewtonStaticCollisionSetDebugCallback?

I'm not sure that a raycast object really generates a collision callback in this case, but maybe i can drop a real object on it to see how it behaves. Do you have a linux (32bit) build of the 2.25? Because i can try it only on linux in these days.

Anyway the car does the same thing on a collision tree and the height field object.
bmwop
 
Posts: 15
Joined: Tue Aug 11, 2009 6:54 am

Re: NewtonTreeCollisionEndBuild crash

Postby Julio Jerez » Tue Oct 05, 2010 7:32 am

But the 2.25 version I posted with the Fix was compiled on Windows, how did you go around the crash to make it work?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonTreeCollisionEndBuild crash

Postby bmwop » Tue Oct 05, 2010 9:43 am

I can use both linux and windows. The linux is more convenient and i can use during work too :)
bmwop
 
Posts: 15
Joined: Tue Aug 11, 2009 6:54 am

Re: NewtonTreeCollisionEndBuild crash

Postby Julio Jerez » Tue Oct 05, 2010 10:26 am

for me I have to use Window because the Linux build has not being updated.
I ususally build Mac and Linux after I complete a milestone, and nwo I am in teh middle of more than one,
otherwise it is too much work debuging in more than one OS.

can you post a copy of teh Linux Build for debugging please? one that uses the DLL
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonTreeCollisionEndBuild crash

Postby bmwop » Tue Oct 05, 2010 10:48 am

can you post a copy of teh Linux Build for debugging please? one that uses the DLL

i think there is a small misunderstanding here, i have tested the 2.25 only on windows and i don't have linux build with the 2.25. Or what linux build do you need?

Anyway it is not a serious problem for me now, so if you don't have much time for debug this than i understand. And i read in some earlier post you are working on some new raycast car.
bmwop
 
Posts: 15
Joined: Tue Aug 11, 2009 6:54 am

Next

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 14 guests