_heapchk fails after NewtonUpdate() :(

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

_heapchk fails after NewtonUpdate() :(

Postby Marc » Thu Feb 10, 2011 4:05 pm

Hi !

It's me again, after some time. It's great you keep working on Newton!

I haven't updated newton since approx. 2.24. But today, I encountered a problem with microsoft's crt heapvalidation functionality in debug compile. It tells me after program completion that something on the heap is corrupt, it found a bad node. I also noticed before that my application crashed when running in release for some time and had no clue what the reason could be. So I checked the docu about the heapvalidation and I found out that I can put _heapchk() anywhere in my code and I checks if the heap is still valid. So I put it at various placed in my code to locate where an when that happens. I found out it always happens exactly after 304 iterations of my main loop, newtonupdate gets called once per mainloop. Everything is deterministic. So I can reproduce it.

Now, the location where the heap gets a bad node is always exactly after the NewtonUpdate call:

Code: Select all
         _heapchk();

         printf("NewtonUpdate start\n");
         NewtonUpdate(newtonworld, 0.016666f);
         printf("NewtonUpdate end\n");

         _heapchk();


I also added _heapchk() at the beginning and end of all newton callbacks I have => heap is ok there. So it seems as if something happens after NewtonUpdate called all callbacks and before it returns to the caller. As I said, it happens after the 304th iteration/call to NewtonUpdate, so most of the time, things go right and just in some circumstance, things go wrong. As a consequence, I decided to update to the current 2.30 version. But the result is the same. Exactly after the 304th iteration at the same place, the _heakchk() fails.

Do you have an idea what could cause this?

I had to change some calls to newton functions in order to make it work with newton 2.30: I call NewtonWorldGetVersion() somewhere at the beginning, back then it needed the newtonworld as a parameter, but I had to remove it. I also added the identity matrix to all my NewtonCreateBody calls as 3rd parameter.
My scene consists of a UserMeshCollision which I provide my own RayHitCallback as well as my own CollideCallback. The rest of the scene are spheres with a upvectorjoint moving around, with 2 different ForceAndTorque-Callbacks.
I saw you mentioned some trouble with vs2010. I'm currently using that right now. What issues did you have with it? Maybe it's related to this somehow?
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: _heapchk fails after NewtonUpdate() :(

Postby Julio Jerez » Thu Feb 10, 2011 4:20 pm

I can check that, but it will reuqire you to provide some demo, and me to spand time figuring my way out.
That time I can use to finish the reorganization of the Directory structure, so that I can upload the next version witch will be Open source.
I estimate that, that will be this satuday or Sunday.

Then you can just down load 2.31 and use the source and see where the crash in happening,

Yes the next version will be Open Source.
Many time bugs are because some bad callback, or some bad data, but that takes lot of my free time, and the resutl is the engine falling behind in features.
This will allow me to focus in the engine and not so much in Bugs and New Platforms.

In the mean time can you link to the Debug DLL? newton 2.30 comes with debug libraries.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: _heapchk fails after NewtonUpdate() :(

Postby Marc » Thu Feb 10, 2011 5:32 pm

I tried linking to the debug library. Sadly, that doesn't give me any more insight. Maybe it's because you compiled against the 2008 runtimes and I compile against the 2010 runtimes? Maybe the usuall debug checks don't catch this problem? I can't add any more _heakchk() calls in between though.

Wow, open src so fast. That'ld be awesome! I'll tweet that ... :)
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: _heapchk fails after NewtonUpdate() :(

Postby Julio Jerez » Thu Feb 10, 2011 6:14 pm

Marc wrote:Maybe it's because you compiled against the 2008 runtimes and I compile against the 2010 runtimes?

yes that's another point open source may help with.
I got VS 2010 projects, but keeping so many platform, and different binaries on the same platform is becoming too difficul to maintain.
The source will have the projects (Mac, Linux and windows) and people can build the platform they want and the compiler they want.

Marc wrote:Wow, open src so fast. That'ld be awesome! I'll tweet that ... :)

Oh thanks
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: _heapchk fails after NewtonUpdate() :(

Postby Marc » Wed Feb 16, 2011 6:09 pm

I found it! It's my fault.

I had an
Code: Select all
    if (o->cuztype = CUZTYPE_UNIT)

, which has to be ==, in my code somewhere and some time later things get screwed up. For some strange reason inside NewtonUpdate. But with the correction, it works. Having been able to compile newton with buffer checks etc. in debug helped a lot. It was slow as hell, but helped me find the problem :D
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany


Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 3 guests

cron