Fail to compile or link to svn

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Fail to compile or link to svn

Postby Julio Jerez » Fri Nov 25, 2011 9:37 am

did you run it?

I just got it and is crash the impommnet I start.
I attached to it from VS and I crash on initialization, this is the stack trace

Code: Select all
    ntdll.dll!772415ee()    
    [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]   
    ntdll.dll!772415ee()    
    ntdll.dll!7723015e()    
>   msvcr90d.dll!operator new(unsigned int size=0)  Line 59 + 0x9 bytes   C++
    0612eba8()   
    pengII.exe!007a6f8e()    
    pengII.exe!00d8633e()    
    pengII.exe!007a333c()    
    ntdll.dll!7724ec42()    
    ntdll.dll!7724eb81()    
    ntdll.dll!7724e951()    
    ntdll.dll!7724e9d6()    
    ntdll.dll!7724ef5b()    
    ntdll.dll!7724ed55()    
    ntdll.dll!7724f3bf()    
    ntdll.dll!7724f1e1()    
    ntdll.dll!7724f24c()    
    ntdll.dll!77253ca3()    
    ntdll.dll!77253cce()    
    ntdll.dll!77256c9a()    
    ntdll.dll!77256c9a()    
    nvoglv32.dll!69b7b3dd()    
    nvoglv32.dll!69bdc533()    
    nvoglv32.dll!69b80392()    
    ntdll.dll!77259930()    
    ntdll.dll!7725a0ba()    
    pengII.exe!00d8629d()    
    kernel32.dll!75f2339a()    
    ntdll.dll!77259ed2()    
    ntdll.dll!77259ea5()    



i chashes on a operator new

Code: Select all
void *__CRTDECL operator new(size_t size) _THROW1(_STD bad_alloc)
        {       // try to allocate size bytes
        void *p;
        while ((p = malloc(size)) == 0)
                if (_callnewh(size) == 0)
                {       // report no memory
                static const std::bad_alloc nomem;
                _RAISE(nomem);
                }

        return (p);
        }


this is a window7 64 bit proffetional,
make sure it runs, and send it again. I liek to see what is wrong but I can no debug that code. but I do not think it has even call the Netwpon world at that point yet.
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Fail to compile or link to svn

Postby Julio Jerez » Fri Nov 25, 2011 9:42 am

I run it from this forder C:\Users\Julio\Downloads\pengII\pengII\Debug

are there any command line or anythong I need to pass?
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Fail to compile or link to svn

Postby JoeJ » Fri Nov 25, 2011 9:46 am

you must run it in:

C:\dev\pengII\pengII\Debug\pengII.exe
so that the data folder is at
C:\dev\pengII\data

paths to ressources in the data folder are hardcoded and there's no check.
Sorry for that, but i've mentioned a few posts above.
User avatar
JoeJ
 
Posts: 1494
Joined: Tue Dec 21, 2010 6:18 pm

Re: Fail to compile or link to svn

Postby Julio Jerez » Fri Nov 25, 2011 9:53 am

Ha it runs now, what it is that I need to do to reprosduce teh crash? tell me again
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Fail to compile or link to svn

Postby Julio Jerez » Fri Nov 25, 2011 9:56 am

never mind I got, and I can see teh bug. let me see what it is stand by.
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Fail to compile or link to svn

Postby Julio Jerez » Fri Nov 25, 2011 10:08 am

Ok I found the bug, is in this function
Code: Select all
dgFloat32 dgCollisionBox::RayCast (const dgVector& localP0, const dgVector& localP1, dgContactPoint& contactOut, OnRayPrecastAction preFilter, const dgBody* const body, void* const userData) const
{
   if (PREFILTER_RAYCAST (preFilter, body, this, userData)) {
      return dgFloat32 (1.2f);
   }

#if 0
   bool cut;
   dgFloat32 t;
   dgFloat32 s;
   dgFloat32 s1;

   cut = false;
   s = dgFloat32 (0.0f);

   dgVector p0 (localP0);
   dgVector p1 (localP1);
   for (int i = 0; i < 3; i ++) {
      dgFloatSign tmp0;
      dgFloatSign tmp1;

      tmp0.m_fVal = m_size[0][i] - p0[i];
      if (tmp0.m_integer.m_iVal > 0) {
         tmp1.m_fVal = m_size[0][i] - p1[i];
         if (tmp1.m_integer.m_iVal < 0) {
            t = tmp0.m_fVal / (p1[i] - p0[i]);
            p1 = p0 + (p1 - p0).Scale (t);

         }
      } else {
         tmp1.m_fVal = m_size[0][i] - p1[i];
         if (tmp1.m_integer.m_iVal > 0) {
            s1 = (m_size[0][i] - localP0[i]) / (localP1[i] - localP0[i]);
            if (s1 > s) {
               s = s1;
               cut = true;
               contactOut.m_normal = dgVector (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f));
               contactOut.m_normal[i] = dgFloat32 (1.0f);
               contactOut.m_userId = SetUserDataID();
            }
            t = tmp0.m_fVal / (p1[i] - p0[i]);
            p0 = p0 + (p1 - p0).Scale (t);
         } else {
            return dgFloat32 (1.2f);
         }
      }
      
      tmp0.m_fVal = -m_size[0][i] - p0[i];
      if (tmp0.m_integer.m_iVal < 0) {
         tmp1.m_fVal = -m_size[0][i] - p1[i];
         if (tmp1.m_integer.m_iVal > 0) {
            t = tmp0.m_fVal / (p1[i] - p0[i]);
            p1 = p0 + (p1 - p0).Scale (t);
         }
      } else {
         tmp1.m_fVal = -m_size[0][i] - p1[i];
         if (tmp1.m_integer.m_iVal < 0) {
            s1 = (-m_size[0][i] - localP0[i]) / (localP1[i] - localP0[i]);
            if (s1 > s) {
               s = s1;
               cut = true;
               contactOut.m_normal = dgVector (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f));
               contactOut.m_normal[i] = -dgFloat32 (1.0f);
               contactOut.m_userId = SetUserDataID();
            }

            t = tmp0.m_fVal / (p1[i] - p0[i]);
            p0 = p0 + (p1 - p0).Scale (t);
         } else {
            return dgFloat32 (1.2f);
         }
      }
   }
   return cut ? s : 1.2f;
#else

   dgInt32 index = 0;
   dgFloat32 signDir = dgFloat32 (0.0f);
   dgFloat32 tmin = dgFloat32 (0.0f);
   dgFloat32 tmax = dgFloat32 (1.0f);
   for (dgInt32 i = 0; i < 3; i++) {
      dgFloat32 dp = localP1[i] - localP0[i];
      if (dgAbsf (dp) < dgFloat32 (1.0e-8f)) {
         if (localP0[i] <= m_size[1][i] || localP0[i] >= m_size[0][i]) {
            return dgFloat32 (1.2f);
         }
      } else {
         dp = dgFloat32 (1.0f) / dp;
         dgFloat32 t1 = (m_size[1][i] - localP0[i]) * dp;
         dgFloat32 t2 = (m_size[0][i] - localP0[i]) * dp;

         dgFloat32 sign = dgFloat32 (-1.0f);
         if (t1 > t2) {
            sign = 1;
            Swap(t1, t2);
         }
         if (t1 > tmin) {
            signDir = sign;
            index = i;
            tmin = t1;
         }
         if (t2 < tmax) {
            tmax = t2;
         }
         if (tmin > tmax) {
            return dgFloat32 (1.2f);
         }
      }
   }

   if (tmin >= dgFloat32 (0.0f)) {
      _ASSERTE (tmin < 1.0f);
      contactOut.m_normal = dgVector (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f));
      contactOut.m_normal[index] = signDir;
      //contactOut.m_userId = SetUserData();
      contactOut.m_userId = SetUserDataID();
   } else {
      tmin = dgFloat32 (1.2f);
   }
   return tmin;
#endif
}

I changed for core 300, to the second form, because it is easier to re-write for SSE with predicates, and yield teh same results as the x87.
the bug is that in code 200, a ray cast should never returns zero.
in core 200 when the hit was zero the last line did this test : return cut ? s : 1.2f; but core 300 is not doing that, I will fix it.
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Fail to compile or link to svn

Postby Julio Jerez » Fri Nov 25, 2011 10:14 am

Ok it is fixed, is was this check here

Code: Select all
   if (tmin >= dgFloat32 (0.0f)) {
      _ASSERTE (tmin < 1.0f);
      contactOut.m_normal = dgVector (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f));
      contactOut.m_normal[index] = signDir;
      //contactOut.m_userId = SetUserData();
      contactOut.m_userId = SetUserDataID();
   } else {


is should be

Code: Select all
   if (tmin > dgFloat32 (0.0f)) {
      _ASSERTE (tmin < 1.0f);
      contactOut.m_normal = dgVector (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f));
      contactOut.m_normal[index] = signDir;
      //contactOut.m_userId = SetUserData();
      contactOut.m_userId = SetUserDataID();
   } else {



sync to svn again.

also you are no realsing the collision chapes after you use then.
It is not big deal bacase the engine will reuse the cache data, but if you detroy the world and recraete new workd several time thet memory leak will grow.

Ther engien has memory debug infomation that cann tell you were teh leak was,
if you opene file ../source\core\dgMemory.h

you can uncoment this line

#ifdef _DEBUG
//#define __TRACK_MEMORY_LEAKS__
#endif

and then on exit you will get a log of the alloncation numbe that produced the leak.
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Fail to compile or link to svn

Postby Julio Jerez » Fri Nov 25, 2011 10:35 am

I enabled memory leak tracking on your test, and I found what it is.
Basically you are releasing the shape the proper way, however you are terminating the engine by an anormal termination from an atexit function.

that is usually not a good idea. Because it will call destrutor but they will not call any cleanup function that migh has to be call before destroying an object.
for example when you exit the world, before teh destrutor is call soem cleanup fontion are call to notify teh subsystem that tose object are no longer live,
they will be detroyed but the code still keep a record house keeping un those objects will not be aware that the are detroyed. basically by not calling Detroy work will look like those object are still live.

In my opninion in general it is never a good idea to use stuff like atexit or singeltons, it is better to go simple

init()
...
prossess();
..
cleanup()
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Fail to compile or link to svn

Postby JoeJ » Mon Nov 28, 2011 10:31 am

I synced again, and found you forgot to remove a post build event from your project:

xcopy "$(OutDir)\$(TargetName).dll" "C:\dev\pengII\pengII\Debug\*.*" /F /Y /R

:)
User avatar
JoeJ
 
Posts: 1494
Joined: Tue Dec 21, 2010 6:18 pm

Re: Fail to compile or link to svn

Postby Julio Jerez » Mon Nov 28, 2011 11:20 am

oh yes thanks I some time debug some demo, and set VS to copy to the fordel so that I can attach to it form VS.
I will remove it.
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Fail to compile or link to svn

Postby Bird » Fri Dec 02, 2011 7:48 pm

I get linker errors like:
1>Physics.obj : error LNK2019: unresolved external symbol __imp__NewtonBodySetTorque referenced in function "void __cdecl ForceAndTorqueCallback(struct NewtonBody const *,float,int)" (?ForceAndTorqueCallback@@YAXPBUNewtonBody@@MH@Z)
1>Physics.obj : error LNK2019: unresolved external symbol __imp__NewtonBodyGetMatrix referenced in function "void __cdecl ForceAndTorqueCallback(struct NewtonBody const *,float,int)" (?ForceAndTorqueCallback@@YAXPBUNewtonBody@@MH@Z)
1>Ragdoll.obj : error LNK2001: unresolved external symbol __imp__NewtonBodyGetMatrix


I believe the linker errors are because in the latest svn versions the preprocessor macro for building a static library has changed from _NEWTON_USE_LIB to _NEWTON_STATIC_LIB. So if you change to _NEWTON_STATIC_LIB in your project you should be able to link to the core_300 static libraries again.

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Previous

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 654 guests