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 in crash handler - Assertion failed at line 2981 of window.cpp #7970

Closed
James103 opened this issue Feb 2, 2020 · 5 comments
Closed
Labels
needs triage This issue needs further investigation before it becomes actionable

Comments

@James103
Copy link
Contributor

James103 commented Feb 2, 2020

Version of OpenTTD

Last tested: d7a928a-windows-win32 (Windows 7 Ultimate)

Expected result

No crash in crash handler

Actual result

Crash in crash handler - Assertion failed at line 2981 of window.cpp: HasModalProgress() || IsLocalCompany()
No crash log created (a crash in the crash handler does not produce a crash log).

Steps to reproduce

??? (Seems to randomly occur, especially with starting new games, testing scripts, loading games, saving the config, etc.)

@LordAro
Copy link
Member

LordAro commented Feb 9, 2020

Extremely difficult to tell what's happened here given just an assertion.

Looking at the code, this function is HandleMouseEvents. This is only called from InputLoop (which is guarded by the same assertion, so it can't be that), and then several places in the win32 video driver, which I must presume you're using. These places are all relating mouse button presses or movements, so I guess you might have more luck reproducing it with lots of those?

As for the failure itself, HasModalProgress is only true during grf scanning and world generation. IsLocalCompany is a check that _current_company == _local_company. There's only a couple of places where this is specifically set to not be true - network commands (not relevant here), Script GameLoop function (also GS::SetCompany) and, oddly, (re)building a company HQ

Hopefully that helps you reproduce whatever's happening :) Ideally we'd fix the issue in the crash handler first, then fix whatever is causing the crash...

@LordAro
Copy link
Member

LordAro commented Apr 4, 2020

Going to close this for now, as there's been no other instances of it, and no way of reproducing it either. Feel free to comment/request reopen if you come up with anything more concrete

@LordAro LordAro closed this as completed Apr 4, 2020
@James103
Copy link
Contributor Author

James103 commented May 25, 2020

Tested on 2020-05-09 master:

  1. Load the first savegame: #4723 - original_savegame.sav
  2. Do not return to the title menu.
  3. Load the second savegame: #4723 - crash.sav
  4. The game will crash with Assertion failed at line 131 of d:\a\1\s\src\pathfinder\follow_track.hpp: ... where what follows is a long if condition that may warrant splitting.
  5. Click "OK" on the error message.
  6. The game may crash with Assertion failed at line 2981 of window.cpp: HasModalProgress() || IsLocalCompany(). This assertion may repeat many times, causing OpenTTD to close anyway.

Note that this is on Windows 10 64-bit.

Additional valid reproduction steps.

  1. Load the attached savegame: #4723 - crash.sav
  2. Pause the game on load and stop all trains.
  3. While the game is paused, go to one of the trains in the "Food Pick" station and make it skip the current order.
  4. Unpause the game. The game will crash with Assertion failed at line 131 of d:\a\1\s\src\pathfinder\follow_track.hpp: ... where what follows is a long if condition that may warrant splitting.
  5. Click "OK" on the error message.
  6. The game may crash with Assertion failed at line 2981 of window.cpp: HasModalProgress() || IsLocalCompany(). This assertion may repeat many times, causing OpenTTD to close anyway

@nielsmh nielsmh reopened this May 25, 2020
@nielsmh nielsmh added needs triage This issue needs further investigation before it becomes actionable and removed waiting on author labels May 25, 2020
@glx22
Copy link
Contributor

glx22 commented May 25, 2020

Ah yes it's when the mouse moves over openttd window while the crash dialog is open.
And _current_company is OWNER_NONE when the assert fails

OpenTTD/src/openttd.cpp

Lines 1376 to 1397 in 800ade7

Backup<CompanyID> cur_company(_current_company, OWNER_NONE, FILE_LINE);
BasePersistentStorageArray::SwitchMode(PSM_ENTER_GAMELOOP);
AnimateAnimatedTiles();
IncreaseDate();
RunTileLoop();
CallVehicleTicks();
CallLandscapeTick();
BasePersistentStorageArray::SwitchMode(PSM_LEAVE_GAMELOOP);
#ifndef DEBUG_DUMP_COMMANDS
{
PerformanceMeasurer framerate(PFE_ALLSCRIPTS);
AI::GameLoop();
Game::GameLoop();
}
#endif
UpdateLandscapingLimits();
CallWindowGameTickEvent();
NewsLoop();
cur_company.Restore();
(pathfinding happens during CallVehicleTicks()

@JGRennison
Copy link
Contributor

I've encountered this before, this commit JGRennison/OpenTTD-patches@102405e is a mitigation.

JGRennison added a commit to JGRennison/Upstream-OpenTTD that referenced this issue May 28, 2020
glx22 added a commit to glx22/OpenTTD that referenced this issue May 29, 2020
@glx22 glx22 closed this as completed in b5ca216 Jun 1, 2020
LordAro pushed a commit to LordAro/OpenTTD that referenced this issue Jun 1, 2020
LordAro pushed a commit to LordAro/OpenTTD that referenced this issue Jun 1, 2020
freprec pushed a commit to freprec/OpenTTD that referenced this issue Jun 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue needs further investigation before it becomes actionable
Projects
None yet
Development

No branches or pull requests

5 participants