Page 1 of 1

[1.0.0] Recursive LocalisedString causes hard crash

Posted: Sat Oct 17, 2020 9:55 pm
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.

Re: [1.0.0] Recursive LocalisedString causes hard crash

Posted: Sat Oct 17, 2020 10:23 pm
by valneq
If a recursive localized string does not make sense, why do you try to create one?

Re: [1.0.0] Recursive LocalisedString causes hard crash

Posted: Sat Oct 17, 2020 10:45 pm
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.

Re: [1.0.0] Recursive LocalisedString causes hard crash

Posted: Sat Oct 17, 2020 10:57 pm
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.

Re: [1.0.0] Recursive LocalisedString causes hard crash

Posted: Sun Oct 18, 2020 10:22 am
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

Re: [1.0.0] Recursive LocalisedString causes hard crash

Posted: Mon Oct 19, 2020 3:50 pm
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.