FreeTexture() crashing

Blitz3D Forums/Blitz3D Programming/FreeTexture() crashing

rgdyman(Posted 2011) [#1]
Hello everyone,.

This crash I am getting has put me in a state of confusion and I
hope someone can shed some light on this for me.

I have a function that will create a window and some buttons.
The detail of the function doesnt seem important for this.

So here is the chunk of code

     ; Background
	Background = CreateQuad(Cam)
	PositionEntity(Background, -10.0, 7.5, 10.0)
	ScaleEntity(Background, 20.0, 15.0, 1.0)
	EntityOrder(Background, 1)
	Tex = LoadTexture("Data\Textures\Menu\Menu.png")
	If Tex = 0 Then RuntimeError("File not found: Data\Textures\Menu\Menu.png!")
	EntityTexture(Background, Tex)
	
	WriteLog(MainLog, "freeing tex: " + Tex)

	FreeTexture(Tex)
	
	WriteLog(MainLog, "freed: " + Tex)



Does anyone out there have any idea why, when FreeTetxure(Tex)
is ran I get a MAV and error out?

The Tex does in fact have a number to it. I double checked in the log
file. This must be a noob thing,. I have never had this before,
well, I have, but the Tex at that time didnt have a number to it.
So naturally I erroed out cause Entity didnt exist. But in this case I do have a number... ?? Im so confused.....
Any help would be great, Thanks :)


Yasha(Posted 2011) [#2]
Have you tried running in debug mode, to get a more detailed error message than MAV?


rgdyman(Posted 2011) [#3]
Truth be told I didnt think of that until after I posted :P

I did finally narrow things down to this function

Function FreeTexture% (texture%)
	If texture<>0 
		Return FreeTexture_ (texture, TextureBuffer(texture))
	Else
		Return 0
	EndIf
End Function


In FastExt.bb

I did comment out the Return just yo get past the error.
Things are running again but the error still exists I just bypassed it.

Blitz points right to the line:

Return FreeTexture_ (texture, TextureBuffer(texture))

Is there is a way to get better feedback than just a line?

Last edited 2011


Warner(Posted 2011) [#4]
Maybe the TextureBuffer is invalid?
Function FreeTexture% (texture%)
	If texture<>0 
                If TextureBuffer(texture) <> 0
  		    Return FreeTexture_ (texture, TextureBuffer(texture))
                End If
	End If
        Return 0
End Function

If this doesn't help, and even in Debugmode, the error is still 'memory access violation', then the error comes from inside the DLL. You could then try installing an earlier version of Blitz3D.


Yasha(Posted 2011) [#5]
Is there is a way to get better feedback than just a line?


Not from the Blitz debugger. FreeTexture_ is a FastExt DLL function, so Blitz3D won't be able to tell you anything more about that, except that whatever caused the program to break happened after the Blitz call on that line. Unfortunately, detailed Debug mode error messages are limited to the built-in functions.

Perhaps it's worth moving this question to the FastExt thread in Userlibs discussion?

Last edited 2011