Page 1 of 1

[0.16.7] pcall crash - Entity is not programmable-speaker

Posted: Mon Dec 25, 2017 11:47 pm
by Aprillion
I was using console to export properties of `game.player` to a JSON file (for debugging a future mod) and found a problem that some properties are not safe to read, e.g.:

Code: Select all

/c game.player.print(type(game.player.character.alert_parameters))

 Cannot execute command. Error: Entity is not programmable-speaker.
When I tried to work around that error, I managed to reliably crash the game (on Mac, no mods, fresh game, log attached). To reproduce, open console (`) and execute following command:

Code: Select all

/c
function crash(node)
  local help = node.help()
  help = help:gsub('.*Values:', '')
  for k in help:gmatch('%s*([^[]+) %[R[^[]*]') do
    local success, result = pcall(function() return node[k] end)
  end
end
crash(game.player.character)
If it helps, following version works, where I didn't combine `pcall` with the `node.help()` ¯\_(ツ)_/¯:

Code: Select all

/c
function works(node)
  local help = 'active [R] alert_parameters [R] speed [R]'
  help = help:gsub('.*Values:', '')
  for k in help:gmatch('%s*([^[]+) %[R[^[]*]') do
    local success, result = pcall(function() return node[k] end)
    game.player.print(k .. ': ' .. tostring(result))
  end
end
works(game.player.character)
I suspect this might be low priority => can I ask for some advice how to detect (skip) unsafe lua table indexes without crashing please?

Re: [0.16.7] pcall crash - Entity is not programmable-speaker

Posted: Tue Dec 26, 2017 7:24 am
by Rseding91
Thanks for the report. I've fixed the crash for the next version of 0.16.

Re: [0.16.7] pcall crash - Entity is not programmable-speaker

Posted: Tue Dec 26, 2017 11:33 am
by Aprillion
Thanks! (hm, unicode thumbsup character is not supported by the forum DB)