Anyone getting access violation in debug only?

BlitzMax Forums/BlitzMax Programming/Anyone getting access violation in debug only?

Grey Alien(Posted 2012) [#1]
I've just been implementing some new DirectX detection code (thread: http://www.blitzbasic.com/Community/posts.php?topic=98989 ) and it works well. However when I added it to my framework I'm getting an EXCEPTION_ACCESS_VIOLATION in debug mode *only*.

Something very weird is going on because if I call this method on my TGame class it's fine:

	Method TestDX()
		DirectXVersion = ccGetDirectXVersion()
		Print DirectXVersion 
		End
	End Method


But if I add that code to the top of another method and call that instead I get the error e.g.

	Method GraphicsCreate(DX7:Int = 0)
		DirectXVersion = ccGetDirectXVersion()
		Print DirectXVersion 
		End
                ...
        end method


It really doesn't make sense and it's been driving me crazy all morning. It's like some kind of memory issue with the debugger or something or maybe the DX code leaves the memory messed up in some way.

Anyway, I'm not expecting a fix as you don't have much to go on but I'm interested to know if anyone else has seen anything like this? I'm using BMax 1.48. Thx

Last edited 2012


skidracer(Posted 2012) [#2]
That is pretty ugly looking code.

When you make an OS call you need to check the return value of every call, using code that blindly assumes all function calls succeed is very bad.

Not reading entire documentation for each call before using it is also very bad.

I would also check the result of things like PeekInt(value_bank_size,0).

Last edited 2012

Last edited 2012


Grey Alien(Posted 2012) [#3]
Thanks.

Turns out the crash went away after col suggested a different way to use kernel32 functions, so I'm good for now, but it was a weird ass crash that didn't make sense.

Last edited 2012