EXCEPTION_ACCESS_VIOLATION (0xc0000005)

I’m getting this error randomly while playing the game I’ve created in Libgdx. Here’s the error log it generated: http://pastebin.java-gaming.org/410373b5b071d

Could anyone explain what it means and how I should try fixing it?

Edit: This is what it says in the console after it crashes: AL lib: (EE) alc_cleanup: 1 device not closed

This might make more sense:

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  com.badlogic.gdx.physics.box2d.World.jniCreateBody(JIFFFFFFFFZZZZZF)J+0
j  com.badlogic.gdx.physics.box2d.World.createBody(Lcom/badlogic/gdx/physics/box2d/BodyDef;)Lcom/badlogic/gdx/physics/box2d/Body;+80
j  com.rayexar.slimeblaster.Projectile.initialise()V+24
j  com.rayexar.slimeblaster.weapons.ElectricBlast.fire(FFLcom/rayexar/slimeblaster/entities/Entity;I)V+82
j  com.rayexar.slimeblaster.entities.Entity.attackWeapon()V+89
j  com.rayexar.slimeblaster.InputHandler.keyUp(I)Z+240
J 1065 C1 com.badlogic.gdx.backends.lwjgl.LwjglInput.processEvents()V (478 bytes) @ 0x0000000002a94dc4 [0x0000000002a94820+0x5a4]
j  com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop()V+557
j  com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run()V+27
v  ~StubRoutines::call_stub

Think this is due to creating a body while World is locked if it is then
maybe:

if (world.isLocked()) return;

What JVM are you using? Oracle or OpenJDK? OpenJDK has many bugs and I wouldn’t recommend using it.
Also it can be caused by a JNI call where you are doing something “bad” (eg. trying to access memory that doesn’t belong to your application). I usually got this kind of errors when I forgot to flip my buffers before uploading them to the GPU.
If you scan through your code and you can’t see anything bad try to reinstall your JRE.

Hey,

Thank you both for the replies, I really didn’t expect to get any replies because this problem seemed uncommon.

Can I find out where the body is being created while the world is locked? The game seems to crash when I fire a “bullet”, but I’ve added a check using if (!world.isLocked()) before creating a body.

I’m using the Oracle JDK, and I’ve just reinstalled JRE and the problem is still there.

I can see that it’s crashing at Projectile.initialise(), but I’m checking the whole initialise() method to make sure that world.isLocked() is false.

The error is being trigged in here somewhere:

public void initialise() {

		if (!world.isLocked()) {
				Gameplay.worldBusy = true;
				shape.setAsBox(hwidth, hheight);
				body = world.createBody(bodyDef);
				body.setTransform(initPos.x, initPos.y, 0);
				fixture = body.createFixture(fixtureDef);
				body.applyLinearImpulse(initImpulse, body.getLocalCenter(),
						true);
				Gameplay.worldBusy = false;
		}
	}

but I can’t see a problem with it. I’m already checking that the world isn’t locked. Can anyone see a problem that would cause the error?

I’ve even made sure that the world doesn’t step if the boolean worldBusy is true, so it can’t be creating a body while stepping.

Edit: Well I’ve spent pretty much the whole day trying to solve this but still can’t :(. Is there a temporary solution to suppress this error (kinda like how you would catch an exception), so that the program will keep running?

I’ve been playing around with the game, and it seems to crash when I try to fire while a Projectile(body) is being destroyed at the same time. Can’t say for sure that this is the problem, but it feels like it when playing. For now I’m just going to make the projectiles that the weapons fire sensors; hopefully that’ll get rid of the problem for now.

Er, wut? That’s news to me.

Cas :slight_smile:

Well, “many” might have been a little extreme. It’s not that bad, but compared to Oracle JDK I’ve experienced way more issues in OpenJDK.

What does “at the same time” mean ? Are you messing with multiple threads ?

The bullets get destroyed when they hit an enemy, or after a period of time. I think the Timer I use creates a new thread

Then you need to properly synchronize access to the Box2d world object.
Or much better, do not use timers and multiple threads at all.