我最近开始在一些我有一段时间没有运行的代码中遇到总线错误,我不确定发生了什么变化,但我希望能够确定原因。不幸的是,我习惯于在 Eclipse 调试器中调试错误,但这在这种情况下无济于事,因为程序只是终止了。
Java information:
Exception type: Bus Error (0xa) at pc=164c38674
Java VM: Java HotSpot(TM) 64-Bit Server VM (20.10-b01-428 mixed mode macosx-amd64)
Current thread (10d8bb800): JavaThread "AWT-EventQueue-0" [_thread_in_native, id=547360768, stack(120901000,120a01000)]
Stack: [120901000,120a01000]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j org.lwjgl.opengl.GL11.nglDrawArrays(IIIJ)V+0
J com.badlogic.gdx.graphics.Mesh.render(Lcom/badlogic/gdx/graphics/glutils/ShaderProgram;III)V
j org.viridia.fta.engine.particles.QuadSpriteBatchRenderer.flush()V+140
J org.viridia.fta.engine.particles.QuadSpriteAppearance.draw(Lorg/viridia/fta/engine/particles/ParticleSystem;Lcom/badlogic/gdx/math/Matrix4;Lcom/badlogic/gdx/math/Matrix4;[Lorg/viridia/fta/engine/particles/Particle;II)V
j org.viridia.fta.engine.particles.ParticleEmitter.render(Lorg/viridia/fta/engine/particles/ParticleSystem;Lcom/badlogic/gdx/math/Matrix4;Lcom/badlogic/gdx/math/Matrix4;)V+16
j org.viridia.fta.engine.particles.ParticleSystem.render(Lcom/badlogic/gdx/math/Matrix4;Lcom/badlogic/gdx/math/Matrix4;)V+29
j org.viridia.tiles.ui.TileMapEditor.render()V+474
j com.badlogic.gdx.backends.lwjgl.LwjglAWTCanvas.render()V+190
j com.badlogic.gdx.backends.lwjgl.LwjglAWTCanvas$1.paintGL()V+4
j org.lwjgl.opengl.AWTGLCanvas.paint(Ljava/awt/Graphics;)V+172
j org.lwjgl.opengl.AWTGLCanvas.update(Ljava/awt/Graphics;)V+2
j sun.awt.RepaintArea.updateComponent(Ljava/awt/Component;Ljava/awt/Graphics;)V+6
j sun.awt.RepaintArea.paint(Ljava/lang/Object;Z)V+305
(ETC...)
最近确实发生了变化的一件事是 OS X“软件更新”服务最近更新了默认 JVM。但是,这可能不是原因 - 我尝试在 Eclipse 中的不同 JVM 下运行并遇到同样的问题。
正如您从堆栈转储中看到的那样,我正在使用轻量级 Java 游戏库,它是通过 libgdx 调用的。据我所知,我自己的代码在这里没有做任何特别的事情,并且在我最后一次尝试时(大约一个月前)它运行良好:
public void flush() {
if (vertexCount > 0 && shader != null) {
mesh.setVertices(vertices, 0, vertexCount);
shader.begin();
Gdx.gl20.glEnable(GL20.GL_BLEND);
Gdx.gl20.glDepthMask(false);
Gdx.gl20.glEnable(GL20.GL_DEPTH_TEST);
if (texture != null && hasTexture) {
texture.bind(0);
shader.setUniformi("uTexture0", 0);
}
shader.setUniformMatrix("uViewXForm", view);
shader.setUniformMatrix("uProjXForm", proj);
mesh.render(shader, GL20.GL_TRIANGLES, 0, vertexCount);
shader.end();
Gdx.gl20.glDepthMask(true);
}
vertexCount = 0;
}