Where to start looking? Illegal Memory Exception

BlitzMax Forums/BlitzMax Programming/Where to start looking? Illegal Memory Exception

Damien Sturdy(Posted 2007) [#1]
Hi All,

With the below code- nothing too special...
BlitzMax crashes out on "Obj:Tvector3 = New Tvector3". you get the first gebug message but not the second.

What sort of problem would cause it to crash on this line? I do not have a "NEW" method or function, so nothing is going on outside of this code.

basically RENDERABLE_getWorldPosition is a C side function which returns a pointer, the rest of the code turns it into pointers you can get/set (and it will alter C side, too.)

Just seems so odd. If i could get an idea as to what things cause this sort of crash and where to look, i'd be moving a little quicker towards my goal haha.
		DebugLog "))))))))))))))))))) Creating Tvector3"
		Local Obj:TVector3 = New TVector3
		DebugLog "Tvector3 created"
		Local tempPointer:Int Ptr = RENDERABLE_getWorldPosition( Self.Pointer )
		Obj.Pointer = Byte Ptr( tempPointer[0] )
		Obj.x = Float Ptr( tempPointer[1] )
		Obj.y = Float Ptr( tempPointer[2] )
		Obj.z = Float Ptr( tempPointer[3] )
		
		Return Obj



skidracer(Posted 2007) [#2]
try a pollsystem or a debugstop after the second debuglog (assuming crash is caused by that c call but the last debug just isn't making it through),

if you have called C functions elsewhere be prepared to consider the fact they have written all over memory,

and make sure you turn quickbuild off


H&K(Posted 2007) [#3]
If you have things like Field X:int = XXXXXXXXXX
The XXXXXXX bit is run on new, so it could be somthing like that. Just because you dont have any New function doesnt mean that some of your code isnt being run on new.


Damien Sturdy(Posted 2007) [#4]
Thanks for the comments. Nothing like that is happening H&K,

Can using Double-Pointers (Using a pointer to a pointer) cause issues?

also, I can't do debugstop, the loop can sometimes run 50-60 times before crashing on that line.

I'll keep looking into the ideas. I'd post more code but there's not much i can post.


Chris C(Posted 2007) [#5]
I had somthing like that driving me nuts when I was messing round with ode, turned out I had a "C" structure slightly wrong so under certain circumstances I was causing the lib to over write somthing.

total b*****d to find I'm afraid, I just had to check and recheck stuff over and over...

pay particular attention to any places where you are inserting values into C structures with Max

pity max cant understand .h files, but you can't have it all (but you can dream!)


Damien Sturdy(Posted 2007) [#6]
Ahhh! Well, i'll look into that- thanks for the help Chris.

It would be useful if a Max type was fully compatible with C. One pointer does the lot. :)


Damien Sturdy(Posted 2007) [#7]
Ok problem solved.

I should really stop trying to play with C stuff!