GC: bad ref

BlitzMax Forums/BlitzMax Programming/GC: bad ref

UNZ(Posted 2013) [#1]
Hi folks,
I'm stuck with this.
I try to wrap the newton game dynamics a little bit but now the gc seems to crash. My wrapper has only a few types to call the newton functions and a pointer to the acutal newton object. I tested newton with the bare function pointers and that works. Please have a look:
https://dl.dropboxusercontent.com/u/63630369/Download-Server/errors/newton%20physics%20bad%20ref.zip

In the download there is the newton dll and my newton.mod.
The test files "newton and ..." work - unless "newton and irrlicht v2.bmx" in whicht I tried to replace the NewtonWorld-Function pointers with my wrapper object. Without the GC it works but with it I get a "bad ref" on a random point in program flow although he shouldn't free anything!

I forgot to say: I'm trying to use it with irrrlicht so you must have the irrlicht mod from gman to run the tests.

Any help is appreciated

EDIT
OH MAN! I just found the mistake:
I put the global functions
-NewtonSetEulerAngle(eulerAngles:Byte Ptr,matrix:Byte Ptr)
-NewtonGetEulerAngle(matrix:Byte Ptr,eulerAngles:Byte Ptr)
in my newton wrapper type NewtonWorld but missed that the parameters are in reverse order in NewtonSetEulerAngle... Looks like that pointer sh** has crashed the GC.

Thats a good example why one wraps stuff, isn't it: now there is an an assert to check the dimensions of the arrays in the wrapper function so that mistakes like these will be detected.