Page 1 of 1

[0.18.32] Crash iterating through all chunks: "LuaHelper::pushTilePosition"

Posted: Thu Jun 18, 2020 4:19 pm
by calcwizard
After creating a ChunkIterator with LuaSurface.get_chunks(), reading all the chunks from it (so that it returns nil), then generating new chunk and trying to read it again causes a game (not script) crash. Specifically, it looks like the new chunks have to be to the south-east, as just south or east doesn't seem cause a crash. Waiting for the chunk generator doesn't prevent the crash, so it doesn't appear to have to do with that.

Steps to recreate:
  1. Start a new map, ideally in sandbox
  2. run a command to create a new iterator and read all the chunks

    Code: Select all

    /c iterator = game.player.surface.get_chunks()
    while iterator() do end
  3. move far south-east to generate new chunks, about 10 chunks southeast of the initially-charted area works reliably
  4. run a command to access the iterator

    Code: Select all

    /c iterator()

Re: [0.18.32] Crash iterating through all chunks: "LuaHelper::pushTilePosition"

Posted: Thu Jun 18, 2020 4:30 pm
by justarandomgeek
I also looked into this a little and it seems to me that what is happening is that when the InfiniteRectangleIterator is being re-initialized for a new call to iterator(), it sometimes takes a path that leaves ->position on it null, but does *not* set the ended status, which later leads to that null pointer being read in an attempt to push that position to lua. Also, the stack trace in the log lists the crash occurring in pushTilePosition, but it actually occurs in pushChunkPosition, the bodies of the two are identical apart from the kind of position type they take, I suspect this is just compilers being "clever".

Re: [0.18.32] Crash iterating through all chunks: "LuaHelper::pushTilePosition"

Posted: Thu Jun 18, 2020 8:43 pm
by Rseding91
Thanks for the report. It's now fixed for the next release.