daily builds after 881 crash all the time on mac

My project works great on daily build 881, but when i use any of the later builds it crashes with a seg fault in random (seemingly physics related) places… anyone else seeing the same?

[import]uid: 118333 topic_id: 30236 reply_id: 330236[/import]

i am getting this error occasionally too, but only in version 891

Lua Runtime Error: lua_pcall failed with status: 2, error message is: ?:0: attempt to index a function value
attempt to call a string value [import]uid: 118333 topic_id: 30236 reply_id: 121106[/import]

and at a risk of a conversation with myself… it seems to be happening on collision events. [import]uid: 118333 topic_id: 30236 reply_id: 121107[/import]

I don’t know whether or not this is in fact a bug but as it was fine until post 881 it seems like something we should be looking into - would you please be so kind as to file a bug report and post the number here for me so I can bring it up in our next meeting? [import]uid: 52491 topic_id: 30236 reply_id: 121117[/import]

Physics was recently updated/changed. I hear certain things are less tolerant than before so it is important you do things correctly. I don’t know the details.

I don’t know what’s going on with the lua_pcall. I thought you generally get line numbers in the simulator. But what ever it is, something is trying to invoke a function on a variable that happens to be a string. You don’t happen to be trampling on some global variables in your code? I once saw somebody do:

debug = false

But debug is a global table containing the standard Lua debug library. When some other module trying calling a function like debug.getinfo(), things broke.

[import]uid: 7563 topic_id: 30236 reply_id: 121118[/import]

thanks for the reply!
i was going to dig around a little more before filing a bug… i’ll file it tomorrow after some
more investigation. I’ve so many different physics things going on, but they are all pretty vanilla things…

cheers
Andy
[import]uid: 118333 topic_id: 30236 reply_id: 121130[/import]

I’m pretty sure it’s something in the collisions, but where i don’t know. i saw the note about isSensor changing relative to collision functions, but i’m not sure if that’s related. i’ll try and dig some more. the lua_pcall only happens sometimes, so i’m not sure if that’s a red herring or not

the crashes seem to happen when my main character interacts with something. and the main character is a ragdoll , so, plenty of places to look. i have

physics.setContinuous(false)  

on, if that matters…
cheers
Andy
[import]uid: 118333 topic_id: 30236 reply_id: 121131[/import]

The Physics library was updated to Box2D 2.2.1 in build 873.
In build 890 there was a change to no longer allows you to set isSensor on an object in a collision event. This was because of changes to Box2d. A new event property was added to handle this (see 890 release notes).

From my experience, if you are getting a runtime Pcall Lua error, your program is doing something wrong. If it’s happening randomly, it’s probably in a collision event.

If you build for developer or debug (instead of adhoc), the runtime error should give you the file and line number of what triggered the error.
[import]uid: 7559 topic_id: 30236 reply_id: 121155[/import]

hey
i don’t doubt it’s something i’m doing, it’s just weird it started happening with the later builds…

i’ve narrowed it down to something specific i think
i precreate some weapons for my hero character like this…

[lua]for i=1,13 do
local asplode = display.newImage(Weapons.dg,“common/blam.png”,-100*i,-100)
asplode.power = 40
physics.addBody( asplode, “dynamic”, { density=1, friction=0, bounce=0 ,radius=explodo,isSensor = true,filter= {categoryBits = 16, maskBits = 269 }} )
–asplode.collision = Weapons.explosion
–asplode:addEventListener(“collision”, asplode)

asplode.id = i
asplode.isVisible = false
asplode.isBodyActive=false
Weapons.asplodes[i]=asplode
end

for i=1,5 do
local ms = display.newImage(Weapons.dg,“missile.png”,-100*i, -100)
physics.addBody(ms, “dynamic”, {friction=0.2,density = 0.50, bounce=0.0,radius = 16,filter = {categoryBits = 16, maskBits = 269 }})

ms.isBullet = true
ms.power = 125
ms.hitCount = 0
ms.isVisible = false
ms.isBodyActive=false
Weapons.missiles[i]=ms
– these are the lines that seem to cause the crash –
ms.collision = Weapons.hitRocket
ms:addEventListener(“collision”, ms)

end [/lua]
if i comment out the two lines relevant to the collision it won’t crash . if the lines are there then it crashes…

i’m a little unclear on the change - can i not use isSensor with a collision function?

cheers
[import]uid: 118333 topic_id: 30236 reply_id: 121191[/import]

Since you didn’t include any of your collision event code (Weapons.explosion), there is no way to say if you are doing something wrong or not.

isSensor is okay to use, but you can’t change it in your collision event code. [import]uid: 7559 topic_id: 30236 reply_id: 121195[/import]

oh yes, that would help

[lua]print(“explosion”)
if (phase == ended) then

local other = event.other
if other ~=nil then
local dx = (other.x - self.x)
local dy = (other.y - self.y)
if dx <= 0 then dx = -1 else dx = 1 end
if dy <= 0 then dy = -1 else dy = 1 end

–print(other)

other:applyLinearImpulse( dx * 50,dy * 50,other.x,other.y)
end
end
return false[/lua]

i don’t get the word ‘explosion’ printed
i’m precreating these objects, then immediately setting them to be inactive until i need them
could that be an issue?

cheers
[import]uid: 118333 topic_id: 30236 reply_id: 121197[/import]

Sorry, but I would need to see the complete event listener to comment. I can’t really help you with only snippets of code. (This is why we ask everyone for a full functional demo project when reporting bugs.)

I would suggest you first figure out which build stopped it from working and then isolate your code to determine what is causing the collision listener to crash. [import]uid: 7559 topic_id: 30236 reply_id: 121198[/import]

well that is the full event listener, minus the function header i accidently snipped off at the top…

the build that it stops working is 890.

883 is fine.

[lua]function Weapons.explosion(self,event)

print(“explosion”)
if (phase == ended) then

local other = event.other
if other ~=nil then
local dx = (other.x - self.x)
local dy = (other.y - self.y)
if dx <= 0 then dx = -1 else dx = 1 end
if dy <= 0 then dy = -1 else dy = 1 end

other:applyLinearImpulse( dx * 50,dy * 50,other.x,other.y)
end
end
return true

end[/lua]

and that is why i haven’t posted a bug yet, i’m trying to isolate the case where it happens.
which isn’t proving that easy as i’m getting no error report other than a segfault, and the call stack just points to code i can’t see.
cheers

[import]uid: 118333 topic_id: 30236 reply_id: 121200[/import]

We would need a complete code sample that fails in order to understand what’s going on. Can you submit a bug report with a simple project that crashes the simulator?

If you keep your objects inactive there will be no collision routine called.

If the simulator crashes right after you start the app, there may be something going on in how your are defining the Weapons table that holds the collision function. Maybe something is clobbering the contents of the table. I don’t know why that would be affected by build 890 changes. [import]uid: 7559 topic_id: 30236 reply_id: 121206[/import]

gah, i think it was some really old button and scene code that was causing a conflict somewhere…
i’ve upgraded to widgets and things seem to be much more stable… sorry for the noise…
[import]uid: 118333 topic_id: 30236 reply_id: 121207[/import]

i am getting this error occasionally too, but only in version 891

Lua Runtime Error: lua_pcall failed with status: 2, error message is: ?:0: attempt to index a function value
attempt to call a string value [import]uid: 118333 topic_id: 30236 reply_id: 121106[/import]

and at a risk of a conversation with myself… it seems to be happening on collision events. [import]uid: 118333 topic_id: 30236 reply_id: 121107[/import]

I don’t know whether or not this is in fact a bug but as it was fine until post 881 it seems like something we should be looking into - would you please be so kind as to file a bug report and post the number here for me so I can bring it up in our next meeting? [import]uid: 52491 topic_id: 30236 reply_id: 121117[/import]

Physics was recently updated/changed. I hear certain things are less tolerant than before so it is important you do things correctly. I don’t know the details.

I don’t know what’s going on with the lua_pcall. I thought you generally get line numbers in the simulator. But what ever it is, something is trying to invoke a function on a variable that happens to be a string. You don’t happen to be trampling on some global variables in your code? I once saw somebody do:

debug = false

But debug is a global table containing the standard Lua debug library. When some other module trying calling a function like debug.getinfo(), things broke.

[import]uid: 7563 topic_id: 30236 reply_id: 121118[/import]

thanks for the reply!
i was going to dig around a little more before filing a bug… i’ll file it tomorrow after some
more investigation. I’ve so many different physics things going on, but they are all pretty vanilla things…

cheers
Andy
[import]uid: 118333 topic_id: 30236 reply_id: 121130[/import]