Memory access violation in glutil.monkey<40>

Monkey Targets Forums/Desktop/Memory access violation in glutil.monkey<40>

MonoDesire(Posted 2016) [#1]
Hi all,

A bit depressed at this point. I had a running environment a week ago, but something has broke...

I am on Win10 using MonkeyXPro86e and mojo2. I am trying to run using the Glfw3 target. I get this runtime error:

Monkey Runtime Error : Memory access violation
C:/Users/Mats/Desktop/INFLUENCE/MonkeyXPro86e/modules/mojo2/glutil.monkey<40>
C:/Users/Mats/Desktop/INFLUENCE/MonkeyXPro86e/modules/mojo2/graphics.monkey<694>
C:/Users/Mats/Desktop/INFLUENCE/MonkeyXPro86e/modules/mojo2/graphics.monkey<784>
C:/Users/Mats/Desktop/INFLUENCE/MonkeyXPro86e/modules/mojo2/graphics.monkey<637>
    :
D:/git/keeprunning/resourcehandler.monkey<26>


Line 40 in glutil.monkey looks like this:
Local shader:=glCreateShader( type )

And line 26 in resourcehandler.monkey looks like this:
backgroundImage = mojo2.Image.Load("main_window/background.png", 0.0, 0.0)

I am not even using shaders, as far as I know. My game is just a simple 2D game. What I do is just to load and draw images.

I am using Visual Studio 2015. As suggested in another thread in the Desktop group, I opened the MonkeyGame.sln file in Visual Studio. The entire solution opened fine (but there were problems running it, maybe same problems as seen when running from within Ted).

I have also tried to install MinGW and set MINGW_PATH="C:\\sdks\MinGW\" and #GLFW_USE_MINGW=True to enable it. Building/linking works fine (as in the case of using VS2015 too), it just crashes in runtime.

Any hints are VERY welcome! :-)


Leginus(Posted 2016) [#2]
I had this problem with GLFW before and spent days checking my code and even backing it out through SVN.
It ran fine in html5 but not GLFW. Would you believe it was a bad image.

Try a different image and see if that fixes it. Loaded fine in html5 but nt GLFW. Obviously its not guaranteed to be the same for you, but no harm in trying.


MonoDesire(Posted 2016) [#3]
@Leginus

Thank you for your hint. It's the same thing here (forgot the mention it my initial post), that I can run my game in HTML5, but not in GLFW.

I have now identified which Git commit the problem occurred in. Unfortunately it's a quite large commit, so I need to read to investigate it for a while. But I think you might be right, it can certainly have something to do with images. I did a quick test and commented out all loading of all images, and I got pass that memory violation. So there is definitely something fishy in that area.

When I find the problem I will write back in here for reference for other people that might run into the same problem.

Thanks so far! :-)


MonoDesire(Posted 2016) [#4]
Okay, so I found out what the problem was. And yes, it was related to how the image was loaded. The problem was that the path to the image was invalid while trying to load it. I had messed up the paths, because I use a sub path for my test bench/code, and it could not access the images in a proper way.

Again, thanks Leginus for pointing out that it could be something with the images! :-)


Leginus(Posted 2016) [#5]
Glad it helped in some way and that you got it sorted :)