2016-09-04 4 views
1

マイゲームがクラッシュした上で時折クラッシュをBOX2D:libgdxは、このメッセージにcreateBody

# A fatal error has been detected by the Java Runtime Environment: 
# 
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000066bcbd0d, pid=13948, tid=12700 
# [...] 
# 
# Problematic frame: 
# C [gdx-box2d64.dll+0xbd0d] 

ログファイルから:

全ログ:同様のクラッシュと他のすべての記事からhttp://pastebin.com/QjY3msYS

起こるべきではないときにはおそらく世界的な改変であろう。食品のコンストラクタで

// generateFood() - called during World.update 
for (int i = 0; i < count; i++) { 
    float x = minX + (float) Math.random() * (maxX - minX); 
    float y = minY + (float) Math.random() * (maxY - minY); 
    Gdx.app.debug("World", "Generating food piece "+i); 
    this.foods.add(new Food(this, x, y, animateGrowth, this.renderable)); 
} 

: クラッシュが新しい食品オブジェクトの作成中に発生し

// in Food(...) constructor 
BodyDef bodyDef = new BodyDef(); //TODO: set to sleep on init? 
bodyDef.type = BodyDef.BodyType.DynamicBody; 
bodyDef.position.set(x, y); 
bodyDef.linearDamping = 0.5f; 
bodyDef.angularDamping = 1f; 
Gdx.app.debug("Food", "Init body with " + bodyDef + " at " + x + "," + y); 
foodBody = world.box2dWorld.createBody(bodyDef); // <== HERE IS WHERE THE CRASH HAPPENS 
CircleShape shape = new CircleShape(); 
shape.setRadius(getSizeFromEnergy()); 
fixtureDef = new FixtureDef(); 
fixtureDef.shape = shape; 
fixtureDef.density = 0.5f; 
fixtureDef.friction = 0.4f; 
fixtureDef.restitution = 0.2f; 
fixture = foodBody.createFixture(fixtureDef); 
fixture.setUserData(this); 
shape.dispose(); 

しかしgenerateFoodコードが正常に実行されたときにのみ、(時々、ゲームプレイの分後に、時折起こります何百回も)。だから私は、クラッシュは食べ物の世代の前に世界と何が起こるかとは関係があると考えました。

public void update() { // Cell.update - called during World.update 
    if (this.energy <= 0) { 
     world.cells.remove(this); 
     Vector2 pos = cellBody.getPosition(); 
     Gdx.app.debug("Cell", "Destroying " + cellBody+" at "+pos.x+","+pos.y); 
     world.box2dWorld.destroyBody(cellBody); // -> Without this line, the crashes don't happen! 
     return; 
    } 
} 

ここでは、ログです:

World: Generating food piece 99 
Food: Init body with [email protected] at -28.201607,-56.101532 
World: Removing cell: [email protected] 
Cell: Destroying [email protected] at -51.92446,-56.464954 
World: Removing cell: [email protected] 
Cell: Destroying [email protected] at -51.92446,-56.464954 
World: Generating 100 new food pieces 
World: Generating food piece 0 
Food: Init body with [email protected] at 14.653984,96.249084 
[...] 
World: Generating food piece 21 
Food: Init body with [email protected] at -15.35305,13.934067 
# 
# A fatal error has been detected by the Java Runtime Environment: 
# 
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000066bcbd0d, pid=9792, tid=13288 
# 

答えて

0
だから、私は クラッシュのみ起こること、を発見するまで、私のセルのBOX2D体の破壊がオブジェクト後にするとき、コードを有効化および無効化を開始しました

私はそれを自分で解決しました。おそらく他のすべての問題のような厄介な小さなバグでした。ログファイルで見ることができるように

、同じセルは二回を削除されています。私は、リストにプレイヤー細胞を二回追加されました:

World: Removing cell: [email protected] 
Cell: Destroying [email protected] at -51.92446,-56.464954 
World: Removing cell: [email protected] 
Cell: Destroying [email protected] at -51.92446,-56.464954 

私はすぐに問題を見つけたことに気づいたとき2回更新し、2回破棄します。これは明らかにbox2dが好きではありませんでした。このようなクラッシュにこれらのソリューション」として

あなたはこのクラッシュを自分で得た場合(あなたのバグが何か他のものになりますので)本当に助けていない、私はrigoriousデバッグして問題を把握しようと提案することができます。 (私はどこにでもたくさんのデバッグログラインを追加し、何時間も出力を調べました...)これらのような間違いが起こるためです。いくつかのより頻繁には、いくつかのために頻繁に、しかし、彼らは起こる。

何か他に追加したいことがあります:box2dクラッシュメッセージは本当に役に立たないです。本当に**本当にクラッシュを引き起こしたものを見つけるのは本当に難しいです。それは吸う。私は、ライブラリ自体(またはlibgdx、おそらく)のようなデバッグ情報、より安全性のチェックとそのようなものがあることを望みます。私は実際にそれらのより多くのを楽しみにしてい

(一見)解けないバグ/ゲームの継続的な発展中のクラッシュ:Z

0

あなたはすでにあなたの問題を解決したが、誰かがこのスレッドに応じstubles場合:私の場合問題は、Box2Dの世界が2回処分されたということでした。

関連する問題