[1.0.0] Recursive LocalisedString causes hard crash

Things that has been reported already before.
Post Reply
Creidhne
Inserter
Inserter
Posts: 27
Joined: Mon Jun 10, 2019 9:43 am
Contact:

[1.0.0] Recursive LocalisedString causes hard crash

Post by Creidhne »

What happened

Attempting to print a recursive LocalisedString via command line causes a hard crash (stack overflow).

Steps to reproduce
  • Start a new game
  • Type the following command:

    Code: Select all

    /c local str = {""}    str[2] = str    game.print(str)
    
Logfile attached.

Expected behaviour

A recursive LocalisedString doesn't make any sense. Expected behaviour is just a nice error message instead of the hard crash.
Attachments
factorio-current.log
(107.64 KiB) Downloaded 10 times

valneq
Filter Inserter
Filter Inserter
Posts: 711
Joined: Fri Jul 12, 2019 7:43 am
Contact:

Re: [1.0.0] Recursive LocalisedString causes hard crash

Post by valneq »

If a recursive localized string does not make sense, why do you try to create one?

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3240
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: [1.0.0] Recursive LocalisedString causes hard crash

Post by DaveMcW »

Creidhne wrote:
Sat Oct 17, 2020 9:55 pm
Expected behaviour is just a nice error message instead of the hard crash.
A table that allows self-references is Turing complete . Therefore you are asking Wube to solve the halting problem.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 4368
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [1.0.0] Recursive LocalisedString causes hard crash

Post by eradicator »

DaveMcW wrote:
Sat Oct 17, 2020 10:45 pm
Creidhne wrote:
Sat Oct 17, 2020 9:55 pm
Expected behaviour is just a nice error message instead of the hard crash.
A table that allows self-references is Turing complete . Therefore you are asking Wube to solve the halting problem.
Detecting recursive tables in lua isn't quite as difficult. You just need to keep references to all ancestors of a table. Any table that is it's own ancestor is recursive.
Author of: Hand Crank Generator Deluxe, Screenshot Hotkey 2.0, /sudo
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Creidhne
Inserter
Inserter
Posts: 27
Joined: Mon Jun 10, 2019 9:43 am
Contact:

Re: [1.0.0] Recursive LocalisedString causes hard crash

Post by Creidhne »

valneq wrote:
Sat Oct 17, 2020 10:23 pm
If a recursive localized string does not make sense, why do you try to create one?
Because I wondered what the game would do in this situation.

Since your question has a strong implicit smell of "Then this bug report is useless. Nothing to fix, just stop doing that", I'll add a little something. This bug enables a user to crash all clients + the server on a multiplayer game (by accident or out of malicious intent). Even if you disable commands on the server, it could still be triggered by other means like .cfg files. cfg files would maybe only crash the player doing it, even with request_translation... I didn't check, and fixing the stack overflow itself requires probably much less dev time than checking all the LocalisedString usage.

A long digression about the Turing-completeness and halting problem applied to LocalisedString
Last edited by Creidhne on Mon Oct 19, 2020 5:08 pm, edited 1 time in total.

Rseding91
Factorio Staff
Factorio Staff
Posts: 11360
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [1.0.0] Recursive LocalisedString causes hard crash

Post by Rseding91 »

Thanks for the report however as with last time this was reported we decided it wasn't worth making the logic slower to guard against a case where there's literally never a reason to do that. 80194

In the same realm as:

Code: Select all

local p = game.player.print; p("thing")
- just don't do that.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Duplicates”

Who is online

Users browsing this forum: No registered users