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

Generating too many news messages at once crashes the game. #7613

Open
James103 opened this issue May 30, 2019 · 3 comments

Comments

@James103
Copy link
Contributor

@James103 James103 commented May 30, 2019

Version of OpenTTD

20190525-master-gef74af6766

Expected result

No crash, instead the game deletes old news when the hard limit of 65,535 news messages is reached.

Actual result

When you generate more than 65,535 news messages while having the news message history window open, the game crashes with Assertion failed at line 673 of d:\a\1\s\src\widget_type.h: num <= MAX_UVALUE(uint16) = 65,535. Crash info has been generated.

Steps to reproduce

There are multiple ways to generate more than 65,535 news messages and crash the game.
Method 1:

  1. Get yourself £(tens of billions) in the bank and/or use BaseCosts newGRF with "stuff with local authority" set to lowest value of /128.
  2. Make sure that the setting "Allow funding road reconstruction" is On.
  3. Open any town's Local Authority window.
  4. Select the action named "Fund local road reconstruction" or "Buy exclusive transport rights".
  5. Pause the game and then perform the town action at least 65,536 times at once.
  6. When you open the news message history window, the game crashes.

Method 2:

  1. Unzip and load up the savegame "gr0_50k_stations63.zip" (note that it will take 500-800 MB RAM to load due to all of the stations).
  2. Open the news message history window.
  3. Wait 10 ingame days. During that time, the game will generate dozens of station acceptance news messages per tick.
  4. The game will crash on 10 Jan 2050 with the same error above.
@James103

This comment has been minimized.

Copy link
Contributor Author

@James103 James103 commented Jun 15, 2019

The assert triggers inside the SetCount() function, which is used whenever a window needs a scrollbar and the scrollbar needs to be updated (it "sets the number of elements in the list"). Therefore, any window that has a scrollbar (not just news message history window) could theoretically trigger the assert, including subsidies, goals, and story page elements.

@James103

This comment has been minimized.

Copy link
Contributor Author

@James103 James103 commented Jul 10, 2019

With OpenTTD 1.9.2 stable, I can give myself £40 billion, buy exclusive transport rights, fund road reconstruction 64,000 (or 65,500) times, scroll the news message history window all the way down, fund road reconstruction another 4,000 (or 100) times, and the scrollbar will disappear. When I try to scroll again, it will appear that all of the 65,536 oldest news messages got deleted at once, leaving only the newest messages. Note that after 6 months, everything resolves itself due to OpenTTD only keeping the 32 recent news message. In those cases, OpenTTD did not crash.

@James103 James103 referenced this issue Oct 20, 2019
1 of 5 tasks complete
@James103

This comment has been minimized.

Copy link
Contributor Author

@James103 James103 commented Oct 20, 2019

Still crashes in 20191006-master-gdd11990ce0.
Crash files have been attached.
Possible cause: The scrollbar on the news history window is too long (max 65535 items).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.