Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Crash]: CTD and incorrect parameter value when adding GSInfo setting with certain int max values #10059

Closed
Arastais opened this issue Sep 28, 2022 · 2 comments
Labels
bug Something isn't working component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language)

Comments

@Arastais
Copy link
Contributor

Arastais commented Sep 28, 2022

Version of OpenTTD

OpenTTD 12.2, Windows 10 64-bit

Steps to reproduce

  1. Create an info.nut file for a game script
  2. Under the GSInfo derived class create a setting
  3. Set the max value of this setting really high (as an example I did 4 billion, i dont know the exact range this happens at)
    • Note that setting this value too high (such as 4 trillion) will cause it to work normally. In this case, if you try to enter 4 billion as a value, it will stop typing at 400 million.
  4. Set the other parameters of the setting to something random (It didn't matter in my testing)
  5. Add a label for this setting for the value 0
  6. Load the game into the "Configure Game Script Parameters" window
  7. Click the dropdown (which is shown instead of a number picker)
  8. Crash the game to desktop

See below for the screenshot at crash time. I have attached a minimal game script setup to test this functionality: MinimalCTDTest.zip

NOTE: if you skip step 5 and do not put a label, the game will not crash but you will instead have incorrect parameters:
image
In this case, it does not show a drop down but the correct number picker, although it is grayed out. Inputting any number into the parameter will cause it to change from 0 to -29496729

Upload crash files

The exception is "0xC0000094: The thread tried to divide an integer value by an integer divisor of zero."
crash20220928063447.log
crash20220928063447

@Arastais Arastais changed the title [Crash]: CTD and incorrect parameter settings when adding GSInfo setting with certain int max values [Crash]: CTD and incorrect parameter value when adding GSInfo setting with certain int max values Sep 28, 2022
@James103
Copy link
Contributor

James103 commented Sep 28, 2022

Can reproduce in d843c8b on Windows 10, 64-bit (via Steam) with the provided Game Script, triggering the following assertion in the process:

assert(this->list.size() > 0);

Crash files: crash20220928064727.zip

Furthermore, depending on the state of openttd.cfg, the game may crash immediately during startup when the NewGRF scan finishes with another assertion (min <= max in Clamp function).
Crash files: crash20220928070001.zip

@glx22
Copy link
Contributor

glx22 commented Sep 28, 2022

It's caused by implicit 64 bit to 32 bit conversions.

@2TallTyler 2TallTyler added component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) bug Something isn't working labels Oct 19, 2022
SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue Feb 3, 2023
Also prevent random_deviation to be below 0.
SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue Feb 3, 2023
…to 12 digits, including '-' for negative numbers
SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue Feb 4, 2023
Also prevent random_deviation to be below 0.
SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue Feb 4, 2023
…to 12 digits, including '-' for negative numbers
SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue Feb 8, 2023
Also prevent random_deviation to be below 0.
SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue Feb 8, 2023
…to 12 digits, including '-' for negative numbers
SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue Feb 18, 2023
Also prevent random_deviation to be below 0.
SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue Feb 18, 2023
@glx22 glx22 closed this as completed in 7b1fd3e Feb 20, 2023
glx22 pushed a commit that referenced this issue Feb 20, 2023
rubidium42 pushed a commit to rubidium42/OpenTTD that referenced this issue Mar 26, 2023
Also prevent random_deviation to be below 0.
rubidium42 pushed a commit to rubidium42/OpenTTD that referenced this issue Mar 26, 2023
rubidium42 pushed a commit to rubidium42/OpenTTD that referenced this issue Mar 28, 2023
Also prevent random_deviation to be below 0.
rubidium42 pushed a commit to rubidium42/OpenTTD that referenced this issue Mar 28, 2023
rubidium42 pushed a commit to rubidium42/OpenTTD that referenced this issue Mar 28, 2023
rubidium42 pushed a commit that referenced this issue Mar 31, 2023
Also prevent random_deviation to be below 0.
rubidium42 pushed a commit that referenced this issue Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language)
Projects
None yet
Development

No branches or pull requests

4 participants