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

This subforum contains all the issues which we already resolved.
User avatar
Aprillion
Inserter
Inserter
Posts: 34
Joined: Sun Apr 16, 2017 10:43 am
Contact:

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

Post 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?
Attachments
factorio-current.log
(8.3 KiB) Downloaded 160 times
Rseding91
Factorio Staff
Factorio Staff
Posts: 14251
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post by Rseding91 »

Thanks for the report. I've fixed the crash for the next version of 0.16.
If you want to get ahold of me I'm almost always on Discord.
User avatar
Aprillion
Inserter
Inserter
Posts: 34
Joined: Sun Apr 16, 2017 10:43 am
Contact:

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

Post by Aprillion »

Thanks! (hm, unicode thumbsup character is not supported by the forum DB)
Post Reply

Return to “Resolved Problems and Bugs”