www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Object overwritten ??? This is crazy

reply David Medlock <amedlock nospam.org> writes:
This seems truly bizarre.

Attached are the two files I am having issue with in DMD v120 on WinXP. 
Compiling these with DMD 119 works just fine.

I have a generic Array template class, which I use as a stack class for 
a Vector math class which implements vector math operations in a 
forth-like manner(push/pop).

My test loop is cut down to the following:

/// Begin Code
void main( char[][] arg )
{
   VecStack vm = new VecStack();
   vm.push( 0, 0, radians(90) );
   double[16] M;
   vm.euler_to_matrix( M );

   // *********** Here vm is now NULL !!!!!

   writefln( "Euler(0,0,90 degrees) -> Matrix" );
   Matrix!(double).Print( M );
   assert( vm.count==0 ); // access violation
}


After calling vm.euler_to_matrix( M ) the vm variable is CLEARED??
Can anyone provide insight here?  I will try to cut it down later, as I 
am at work.

-David
Apr 07 2005
next sibling parent David Medlock <amedlock nospam.org> writes:
David Medlock wrote:

 This seems truly bizarre.
 
 Attached are the two files I am having issue with in DMD v120 on WinXP. 
 Compiling these with DMD 119 works just fine.
 
 I have a generic Array template class, which I use as a stack class for 
 a Vector math class which implements vector math operations in a 
 forth-like manner(push/pop).
 
 My test loop is cut down to the following:
 
 /// Begin Code
 void main( char[][] arg )
 {
   VecStack vm = new VecStack();
   vm.push( 0, 0, radians(90) );
   double[16] M;
   vm.euler_to_matrix( M );
 
   // *********** Here vm is now NULL !!!!!
 
   writefln( "Euler(0,0,90 degrees) -> Matrix" );
   Matrix!(double).Print( M );
   assert( vm.count==0 ); // access violation
 }
 
 
 After calling vm.euler_to_matrix( M ) the vm variable is CLEARED??
 Can anyone provide insight here?  I will try to cut it down later, as I 
 am at work.
 
 -David
The plot thickens. I think I have it narrowed down to this function: final void quat_to_matrix( double[16] M ) // ( q -- ) { normalize(); quat v = pop(); double xx = v.x*v.x; double xz = v.x*v.z; double xy = v.x*v.y; double xw = v.x*v.w; double yy = v.y*v.y; double yz = v.y*v.z; double yw = v.y*v.w; double zz = v.z*v.z; double zw = v.z*v.w; M[] = 0; M[15] = 1; M[0] = 1 - 2 * (yy + zz) ; M[1] = 2 * (xy + zw) ; M[2] = 2 * (xz - yw) ; M[4] = 2 * (xy - zw) ; M[5] = 1 - 2 * (xx + zz) ; M[6] = 2 * (yz + xw) ; M[8] = 2 * (xz + yw) ; M[9] = 2 * (yz - xw) ; M[10] = 1 - 2 * (xx + yy) ; } The line which is the problem is: M[] = 0; Since M is passed on the stack it overwrites itself and part of the calling stack frame, it appears. What is weird is that function is called by euler_to_quat() , but if you call quat_to_matrix() directly then no access violation. Walter, is this a bug in the code generator? -David
Apr 07 2005
prev sibling parent reply Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David Medlock schrieb am Thu, 07 Apr 2005 10:49:31 -0400:
 This seems truly bizarre.

 Attached are the two files I am having issue with in DMD v120 on WinXP. 
 Compiling these with DMD 119 works just fine.

 I have a generic Array template class, which I use as a stack class for 
 a Vector math class which implements vector math operations in a 
 forth-like manner(push/pop).

 My test loop is cut down to the following:

 /// Begin Code
 void main( char[][] arg )
 {
    VecStack vm = new VecStack();
    vm.push( 0, 0, radians(90) );
    double[16] M;
    vm.euler_to_matrix( M );

    // *********** Here vm is now NULL !!!!!

    writefln( "Euler(0,0,90 degrees) -> Matrix" );
    Matrix!(double).Print( M );
    assert( vm.count==0 ); // access violation
 }


 After calling vm.euler_to_matrix( M ) the vm variable is CLEARED??
 Can anyone provide insight here?  I will try to cut it down later, as I 
 am at work.
Added to DStress as http://dstress.kuehne.cn/run/bug_20050407_01.d http://dstress.kuehne.cn/run/bug_20050407_02.d http://dstress.kuehne.cn/run/bug_20050407_03.d Thomas PS: thanks heaven for automatic bug cutters *g* -----BEGIN PGP SIGNATURE----- iD8DBQFCVXwK3w+/yD4P9tIRApi9AJ0XOCpeBlz2R+RScZSq7P2MCLEFlgCeOh0s vdIuX2uDPKQQA0NfKwDnhX8= =6Pi3 -----END PGP SIGNATURE-----
Apr 07 2005
parent reply David Medlock <nospam nospam.com> writes:
Thomas Kuehne wrote:
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
 David Medlock schrieb am Thu, 07 Apr 2005 10:49:31 -0400:
 
This seems truly bizarre.

Attached are the two files I am having issue with in DMD v120 on WinXP. 
Compiling these with DMD 119 works just fine.

I have a generic Array template class, which I use as a stack class for 
a Vector math class which implements vector math operations in a 
forth-like manner(push/pop).

My test loop is cut down to the following:

/// Begin Code
void main( char[][] arg )
{
   VecStack vm = new VecStack();
   vm.push( 0, 0, radians(90) );
   double[16] M;
   vm.euler_to_matrix( M );

   // *********** Here vm is now NULL !!!!!

   writefln( "Euler(0,0,90 degrees) -> Matrix" );
   Matrix!(double).Print( M );
   assert( vm.count==0 ); // access violation
}


After calling vm.euler_to_matrix( M ) the vm variable is CLEARED??
Can anyone provide insight here?  I will try to cut it down later, as I 
am at work.
Added to DStress as http://dstress.kuehne.cn/run/bug_20050407_01.d http://dstress.kuehne.cn/run/bug_20050407_02.d http://dstress.kuehne.cn/run/bug_20050407_03.d Thomas PS: thanks heaven for automatic bug cutters *g*
LOL. Thanks for chopping that down, Thomas. (You don't really have such a program do you ? ;) I am very interested how the stack frame is getting clobbered, though. Whatever quibbles we have over syntax and semantics, correctness is of paramount importance for confidence in DMD. -DavidM
Apr 07 2005
parent reply Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David Medlock schrieb am Thu, 07 Apr 2005 16:24:31 -0400:
 Thomas Kuehne wrote:
<snip>
 
 PS: thanks heaven for automatic bug cutters *g*
 
LOL. Thanks for chopping that down, Thomas. (You don't really have such a program do you ? ;)
Sure I do. It did cut your posted code by factor 12. The remaining factor 0.11 was my intervention. Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCVZrd3w+/yD4P9tIRAvy0AJsFIaSHzsEYHterRLazK+HaNa6DFgCcCf5i VvNH3ZQRZnZsg3ajaR6O1jQ= =6QVE -----END PGP SIGNATURE-----
Apr 07 2005
parent reply "Charlie" <charles jwavro.com> writes:
Where'd you get this magical program :) ?

Charlie!

"Thomas Kuehne" <thomas-dloop kuehne.thisisspam.cn> wrote in message
news:tfigi2-6t3.ln1 lnews.kuehne.cn...
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1

 David Medlock schrieb am Thu, 07 Apr 2005 16:24:31 -0400:
 Thomas Kuehne wrote:
<snip>
 PS: thanks heaven for automatic bug cutters *g*
LOL. Thanks for chopping that down, Thomas. (You don't really have such a program do you ? ;)
Sure I do. It did cut your posted code by factor 12. The remaining factor 0.11 was my intervention. Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCVZrd3w+/yD4P9tIRAvy0AJsFIaSHzsEYHterRLazK+HaNa6DFgCcCf5i VvNH3ZQRZnZsg3ajaR6O1jQ= =6QVE -----END PGP SIGNATURE-----
Apr 07 2005
parent Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Charlie schrieb am Thu, 7 Apr 2005 15:47:22 -0500:
 Where'd you get this magical program :) ?

 Charlie!
custom inhouse development Thomas
 "Thomas Kuehne" <thomas-dloop kuehne.thisisspam.cn> wrote in message
 news:tfigi2-6t3.ln1 lnews.kuehne.cn...
 David Medlock schrieb am Thu, 07 Apr 2005 16:24:31 -0400:
 Thomas Kuehne wrote:
<snip>
 PS: thanks heaven for automatic bug cutters *g*
LOL. Thanks for chopping that down, Thomas. (You don't really have such a program do you ? ;)
Sure I do. It did cut your posted code by factor 12. The remaining factor 0.11 was my intervention.
-----BEGIN PGP SIGNATURE----- iD8DBQFCVhud3w+/yD4P9tIRAjsEAJ9hwMQ6DrbFHDRxR0wkgBZ9//2YuQCfV78j P/sX90hW9QIh6MUwMF2U6QI= =izG4 -----END PGP SIGNATURE-----
Apr 07 2005