EXC_BAD_ACCESS on device on b2PolygonShape

Hello

I get a EXC_BAD_ACCESS when running the game on the iphone. Under the simulator it
runs fine. It stops in b2PolygonShape::Clone when one goes to create a fixture on a body.

Any help would be appreciated.

c
Is it possible that the device has simply run out of memory?
Could be, I was thinking about this fact today, i am going to check this today and report back.

Thanks
c
I rebooted the phone and the same problem.

It dies in this function,

Code: Select all

b2Shape* b2PolygonShape::Clone(b2BlockAllocator* allocator) const
{
   void* mem = allocator->Allocate(sizeof(b2PolygonShape));
   b2PolygonShape* clone = new (mem) b2PolygonShape;
   *clone = *this;
   return clone;
}


on the line "*clone= *this"
Are you sure that the shape you are copying is valid? Is there anything else that is different on the device to the simulator?
The stack trace is as follows:

Code: Select all

#0  0x00020a1c in b2PolygonShape::operator= (this=0xae73c6) at b2PolygonShape.h:27
#1  0x000209d0 in b2PolygonShape::Clone (this=0x2fdfe1a4, allocator=0x7800000) at /gggggg/Box2D/Collision/Shapes/b2PolygonShape.cpp:32
#2  0x00023692 in b2Fixture::Create (this=0xafc904, allocator=0x7800000, broadPhase=0x78191d8, body=0xae7324, xf=@0xae732c, def=0x2fdfe278) at /gggggg/Box2D/Dynamics/b2Fixture.cpp:57
#3  0x00021e58 in b2Body::CreateFixture (this=0xae7324, def=0x2fdfe278) at /ggggg/Box2D/Dynamics/b2Body.cpp:137
#4  0x000109d2 in -[GameLayer addBodyToPhysicsWorld:] (self=0xae3800, _cmd=0x22758d, physicsbody=0x6ed3e0) at /ggggg/Classes/GameLayer.mm:1537

Problem Solved. It seems another object was incorrectly destroyed right before this object creation. Once i fixed this, everything worked fine. I cant explain it and just happy its working

thanks
c

Original thread: https://box2d.org/forum/viewtopic.php?t=7282