world-of-might-and-magic icon indicating copy to clipboard operation
world-of-might-and-magic copied to clipboard

Crash when entering the Haunted Mansion

Open perrelle opened this issue 11 months ago • 20 comments

Describe the bug The game window closes when entering the Haunted Mansion in Barrow Downs

To Reproduce Steps to reproduce the behaviour:

  1. Load autosave.mm7
  2. Click on the Mansion's door
  3. Click on 'Ok'
  4. The game window closes

Expected behavior No crash, the player should be able to enter the mansion

Environment (please complete the following information):

  • OS: Windows
  • Architecture: x64
  • Version: Windows 10 Professionnel 22H2

Screenshots NA

Saved game file autosave.zip

Additional context

perrelle avatar Mar 26 '24 23:03 perrelle

Unable to replicate on current master win 11 x64

pskelton avatar Mar 29 '24 22:03 pskelton

we were unable to replicate it as well, and his stacktrace was wacky

Stack trace (most recent call last): #26 Object "", at 00007FF819377344, in BaseThreadInitThunk Tentative d#25 Object "", at 00007FF68081E55E, in ?? Tentative d#24 Object "", at 00007FF68081E2FE, in ?? Tentative d#23 Object "", at 00007FF68081E43E, in ?? Tentative d#22 Object "", at 00007FF68081E4E9, in ?? Tentative d#21 Object "", at 00007FF680912562, in ?? Tentative d#20 Object "", at 00007FF6809124D5, in ?? Tentative d#19 Object "", at 00007FF67FC18FCC, in ?? Tentative d#18 Object "", at 00007FF67FC1A33C, in ?? Tentative d#17 Object "", at 00007FF67FC1C221, in ?? Tentative d#16 Object "", at 00007FF67FC1C083, in ?? Tentative d#15 Object "", at 00007FF67FC85136, in ?? Tentative d#14 Object "", at 00007FF67FCB4770, in ?? Tentative d#13 Object "", at 00007FF67FCB4809, in ?? Tentative d#12 Object "", at 00007FF67FCBF777, in ?? Tentative d#11 Object "", at 00007FF67FD5E354, in ?? Tentative d#10 Object "", at 00007FF67FD5E7B9, in ?? Tentative d#9 Object "", at 00007FF67FE08A37, in ?? Tentative d#8 Object "", at 00007FF67FE08D45, in ?? Tentative d#7 Object "", at 00007FF67FE688AD, in ?? Tentative d#6 Object "", at 00007FF67FE06A82, in ?? Tentative d#5 Object "", at 00007FF67FE3EE17, in ?? Tentative d#4 Object "", at 00007FF67FCE89B3, in ?? Tentative d#3 Object "", at 00007FF68088F270, in ?? Tentative d#2 Object "", at 00007FF6808EACD9, in ?? Tentative d#1 Object "", at 00007FF68088F353, in ?? Tentative d#0 Object "", at 00007FF68088EAB0, in ??

botanicvelious avatar Mar 30 '24 01:03 botanicvelious

Didn't crash for me either. I'd try disabling antivirus (add as exclusion) and making sure no external overlay program is trying to hook into the game.

Novicek avatar Mar 30 '24 02:03 Novicek

I have just built it from source. This gave me a useful stacktrace:

Stack trace (most recent call last):
#26   Object "", at 00007FFD2B507344, in BaseThreadInitThunk
#25   Source "D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp", line 17, in mainCRTStartup [00007FF6EDAEABFE]
#24   Source "D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl", line 331, in __scrt_common_main [00007FF6EDAEA99E]
#23   Source "D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl", line 288, in __scrt_common_main_seh [00007FF6EDAEAADE]
#22   Source "D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl", line 79, in invoke_main [00007FF6EDAEAB89]
#21   Source "D:\a\OpenEnroth_Dependencies\OpenEnroth_Dependencies\repos\sdl\src\main\windows\SDL_windows_main.c", line 95, in main [00007FF6EDBA5302]
#20   Source "D:\a\OpenEnroth_Dependencies\OpenEnroth_Dependencies\repos\sdl\src\main\windows\SDL_windows_main.c", line 80, in main_getcmdline [00007FF6EDBA5275]
#19   Source "D:\Jeux\OpenEnroth\OpenEnroth\src\Library\Platform\Sdl\SdlMain.cpp", line 8, in SDL_main [00007FF6ECEF2C3C]
          5: // This gets #defined by SDL into SDL_main.
          6: int main(int argc, char **argv) {
          7:     return platformMain(argc, argv);
      >   8: }
#18   Source "D:\Jeux\OpenEnroth\OpenEnroth\src\Bin\OpenEnroth\OpenEnroth.cpp", line 149, in platformMain [00007FF6ECE88D3C]
        146: }
        147:
        148: int platformMain(int argc, char **argv) {
      > 149:     int result = openEnrothMain(argc, argv);
        150:
        151: #ifdef _WINDOWS
        152:     // SDL on Windows creates a separate console window, and we want to be able to actually read the error message
#17   Source "D:\Jeux\OpenEnroth\OpenEnroth\src\Bin\OpenEnroth\OpenEnroth.cpp", line 138, in openEnrothMain [00007FF6ECE8AC31]
        136:         switch (options.subcommand) {
        137:         default: assert(false); [[fallthrough]];
      > 138:         case OpenEnrothOptions::SUBCOMMAND_GAME: return runOpenEnroth(options);
        139:         case OpenEnrothOptions::SUBCOMMAND_PLAY: return runPlay(options);
        140:         case OpenEnrothOptions::SUBCOMMAND_RETRACE: return runRetrace(options);
        141:         }
#16   Source "D:\Jeux\OpenEnroth\OpenEnroth\src\Bin\OpenEnroth\OpenEnroth.cpp", line 124, in runOpenEnroth [00007FF6ECE8AA93]
        121: }
        122:
        123: int runOpenEnroth(const OpenEnrothOptions &options) {
      > 124:     GameStarter(options).run();
        125:     return 0;
        126: }
#15   Source "D:\Jeux\OpenEnroth\OpenEnroth\src\Application\GameStarter.cpp", line 195, in GameStarter::run [00007FF6ECEF4A66]
        192: void GameStarter::run() {
        193:     _game->run();
        194:
      > 195:     if (_options.useConfig) {
        196:         _application->component<GameWindowHandler>()->UpdateConfigFromWindow(_config.get());
        197:         _config->save(_options.configPath);
        198:         logger->info("Configuration file '{}' saved!", _options.configPath);
#14   Source "D:\Jeux\OpenEnroth\OpenEnroth\src\Application\Game.cpp", line 146, in Game::run [00007FF6ECF24520]
        143:         GUIWindow_MainMenu::loop();
        144:         uGameState = GAME_STATE_PLAYING;
        145:
      > 146:         if (!loop()) {
        147:             break;
        148:         }
        149:     }
#13   Source "D:\Jeux\OpenEnroth\OpenEnroth\src\Application\Game.cpp", line 165, in Game::loop [00007FF6ECF245B9]
        162:                 uGameState = GAME_STATE_PLAYING;
        163:                 gameLoop();
        164:             }
      > 165:             if (uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU) {
        166:                 SetCurrentMenuID(MENU_NEWGAME);
        167:                 uGameState = GAME_STATE_PLAYING;
        168:                 continue;
#12   Source "D:\Jeux\OpenEnroth\OpenEnroth\src\Application\Game.cpp", line 1944, in Game::gameLoop [00007FF6ECF2F87E]
       1942:             if (uGameState == GAME_STATE_PLAYING) {
       1943:                 engine->Draw();
      >1944:                 continue;
       1945:             }
       1946:
       1947:             if (uGameState == GAME_STATE_CHANGE_LOCATION) {  // смена локации
#11   Source "D:\Jeux\OpenEnroth\OpenEnroth\src\Engine\Engine.cpp", line 206, in Engine::Draw [00007FF6ECFD0154]
        203: //----- (0044103C) --------------------------------------------------------
        204: void Engine::Draw() {
        205:     drawWorld();
      > 206:     drawHUD();
        207:
        208:     render->Present();
        209: }
#10   Source "D:\Jeux\OpenEnroth\OpenEnroth\src\Engine\Engine.cpp", line 170, in Engine::drawWorld [00007FF6ECFD05B9]
        168:             if (uCurrentlyLoadedLevelType == LEVEL_INDOOR) {
        169:                 pIndoor->Draw();
      > 170:             } else {
        171:                 assert(uCurrentlyLoadedLevelType == LEVEL_OUTDOOR);
        172:                 render->uFogColor = GetLevelFogColor();
        173:                 pOutdoor->Draw();
#9    Source "D:\Jeux\OpenEnroth\OpenEnroth\src\Engine\Graphics\Indoor.cpp", line 219, in IndoorLocation::Draw [00007FF6ED07AAA7]
        216:     PrepareDrawLists_BLV();
        217:     if (pBLVRenderParams->uPartySectorID)
        218:         DrawIndoorFaces(true);
      > 219:     render->TransformBillboardsAndSetPalettesODM();
        220:     engine->DrawParticles();
        221:     trail_particle_generator.UpdateParticles();
        222: }
#8    Source "D:\Jeux\OpenEnroth\OpenEnroth\src\Engine\Graphics\Indoor.cpp", line 210, in IndoorLocation::DrawIndoorFaces [00007FF6ED07ADB5]
        207: //----- (00440B44) --------------------------------------------------------
        208: void IndoorLocation::DrawIndoorFaces(bool bD3D) {
        209:     render->DrawIndoorFaces();
      > 210: }
#7    Source "D:\Jeux\OpenEnroth\OpenEnroth\src\Engine\Graphics\Renderer\OpenGLRenderer.cpp", line 3908, in OpenGLRenderer::DrawIndoorFaces [00007FF6ED0DA5FD]
       3905:                 BLVFace *face = &pIndoor->pFaces[test];
       3906:
       3907:                 if (face->isPortal()) continue;
      >3908:                 if (!face->GetTexture()) continue;
       3909:                 //if (face->uAttributes & FACE_IS_DOOR) continue;
       3910:
       3911:                 // TODO(pskelton): Same as outdoors. When ODM and BLV face is combined - seperate out function
#6    Source "D:\Jeux\OpenEnroth\OpenEnroth\src\Engine\Graphics\Indoor.cpp", line 241, in BLVFace::GetTexture [00007FF6ED078AE2]
        238:     if (this->IsTextureFrameTable())
        239:         // TODO(captainurist): using pEventTimer here is weird. This means that e.g. cleric in the haunted mansion is
        240:         //                     not animated in turn-based mode. Use misc timer? Also see ODMFace::GetTexture.
      > 241:         return pTextureFrameTable->GetFrameTexture(
        242:             (int64_t)this->resource, pEventTimer->time());
        243:     else
        244:         return static_cast<GraphicsImage *>(this->resource);
#5    Source "D:\Jeux\OpenEnroth\OpenEnroth\src\Engine\Graphics\TextureFrameTable.cpp", line 26, in TextureFrameTable::GetFrameTexture [00007FF6ED0B0CF7]
         23: }
         24:
         25: GraphicsImage *TextureFrameTable::GetFrameTexture(int frameId, Duration offset) {
      >  26:     Duration animationDuration = textures[frameId].animationDuration;
         27:
         28:     if ((textures[frameId].flags & TEXTURE_FRAME_TABLE_MORE_FRAMES) && animationDuration) {
         29:         offset = offset % animationDuration;
#4    Source "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\vector", line 1893, in std::vector<ObjectDesc,std::allocator<ObjectDesc> >::operator[] [00007FF6ECF58C63]
       1890:     _NODISCARD _CONSTEXPR20 _Ty& operator[](const size_type _Pos) noexcept /* strengthened */ {
       1891:         auto& _My_data = _Mypair._Myval2;
       1892: #if _CONTAINER_DEBUG_LEVEL > 0
      >1893:         _STL_VERIFY(
       1894:             _Pos < static_cast<size_type>(_My_data._Mylast - _My_data._Myfirst), "vector subscript out of range");
       1895: #endif // _CONTAINER_DEBUG_LEVEL > 0
#3    Source "minkernel\crts\ucrt\src\appcrt\misc\dbgrpt.cpp", line 263, in _CrtDbgReport [00007FF6EDB22000]
#2    Source "minkernel\crts\ucrt\src\appcrt\misc\dbgrptt.cpp", line 420, in _VCrtDbgReportA [00007FF6EDB7DA69]
#1    Source "minkernel\crts\ucrt\src\appcrt\misc\dbgrpt.cpp", line 453, in __acrt_MessageWindowA [00007FF6EDB220E3]
#0    Source "minkernel\crts\ucrt\src\appcrt\misc\dbgrpt.cpp", line 427, in common_message_window<char> [00007FF6EDB21840]

Sortie de D:\Jeux\OpenEnroth\OpenEnroth\out\build\x64-Debug\src\Bin\OpenEnroth\Debug\OpenEnroth.exe (processus 22544). Code : 3.

perrelle avatar Apr 01 '24 03:04 perrelle

Just as a sanity check, can you confirm that the same save loaded into the normal game works as expected for you?

The issue will be when its looking up the animated priest painting texture. However I am not sure yet as to why the TextureFrameTable is not populating for you.

pskelton avatar Apr 02 '24 21:04 pskelton

Yes, there is no crash with the same save on the original game.

perrelle avatar Apr 03 '24 01:04 perrelle

Your branch fixes the crash. I don't know where the log is located, I could not find it.

perrelle avatar Apr 03 '24 01:04 perrelle

Log message would be printed somewhere in the console window. You may need to change the "log_level" setting in OpenEnroth.ini to "warning" for it to show up though. Or if you have any knowledge of debugging could put a break point in and interrogate values.

pskelton avatar Apr 03 '24 21:04 pskelton

What happens when you look at this now? Screenshot 2024-04-03 220949

pskelton avatar Apr 03 '24 21:04 pskelton

There is not output on the console window. I can try to set a break point, but I will need to familiarize with VS first. The portrait is empty on my version : image

perrelle avatar Apr 04 '24 03:04 perrelle

frameId is way beyond the boundaries with a value of 1495369312 while textures.size() is 19

perrelle avatar Apr 07 '24 09:04 perrelle

frameId is way beyond the boundaries with a value of 1495369312 while textures.size() is 19

Is this with latest master? I have made changes to use a fixed width int because I thought that something like this could occur.

pskelton avatar Apr 07 '24 09:04 pskelton

No, I've been using your branch.

perrelle avatar Apr 07 '24 09:04 perrelle

On master, I still have the problem, but the int64_t type allows for a bigger value : 2542856067488. It does seem like some uninitialized value.

perrelle avatar Apr 07 '24 10:04 perrelle

Is that number consistent between repeated runs?

pskelton avatar Apr 07 '24 10:04 pskelton

No, it is not :

[2024-04-07 12:15:52.388] [error] Failed to retreive OOB frameID '2202524559328' from TextureFrameTable::GetFrameTexture

perrelle avatar Apr 07 '24 10:04 perrelle

Could you use this branch and give me the dump output of the table. Your table is not what we expect as it only has 19 entries. What version of the MM7 are you using?

pskelton avatar Apr 07 '24 18:04 pskelton

Here it is :

[2024-04-07 20:21:41.639] [warning] Entry 0: name-null frameDur-0 animDur-0 flags-2
[2024-04-07 20:21:45.748] [warning] Entry 1: name-mossrk_2 frameDur-64 animDur-896 flags-3
[2024-04-07 20:21:45.750] [warning] Entry 2: name-woodtl_1 frameDur-64 animDur-0 flags-1
[2024-04-07 20:21:45.750] [warning] Entry 3: name-mossrk_2 frameDur-128 animDur-0 flags-1
[2024-04-07 20:21:45.750] [warning] Entry 4: name-woodtl_1 frameDur-128 animDur-0 flags-1
[2024-04-07 20:21:45.751] [warning] Entry 5: name-mossrk_2 frameDur-256 animDur-0 flags-1
[2024-04-07 20:21:45.751] [warning] Entry 6: name-woodtl_1 frameDur-256 animDur-0 flags-0
[2024-04-07 20:21:45.752] [warning] Entry 7: name-john01 frameDur-32 animDur-192 flags-3
[2024-04-07 20:21:45.752] [warning] Entry 8: name-john02 frameDur-32 animDur-0 flags-1
[2024-04-07 20:21:45.753] [warning] Entry 9: name-john03 frameDur-32 animDur-0 flags-1
[2024-04-07 20:21:45.753] [warning] Entry 10: name-john04 frameDur-32 animDur-0 flags-1
[2024-04-07 20:21:45.754] [warning] Entry 11: name-john05 frameDur-32 animDur-0 flags-1
[2024-04-07 20:21:45.754] [warning] Entry 12: name-john06 frameDur-32 animDur-0 flags-0
[2024-04-07 20:21:45.755] [warning] Entry 13: name-paladn01 frameDur-32 animDur-192 flags-3
[2024-04-07 20:21:45.755] [warning] Entry 14: name-paladn02 frameDur-32 animDur-0 flags-1
[2024-04-07 20:21:45.755] [warning] Entry 15: name-paladn03 frameDur-32 animDur-0 flags-1
[2024-04-07 20:21:45.756] [warning] Entry 16: name-paladn04 frameDur-32 animDur-0 flags-1
[2024-04-07 20:21:45.756] [warning] Entry 17: name-paladn05 frameDur-32 animDur-0 flags-1
[2024-04-07 20:21:45.756] [warning] Entry 18: name-paladn06 frameDur-32 animDur-0 flags-0

perrelle avatar Apr 07 '24 18:04 perrelle

There may be a problem with the GoG version of the game.

https://www.gog.com/forum/might_and_magic_series/mm7_crash_to_desktop_in_barrow_downs_haunted_house

The problem only appears when being able to look at the priest portrait, not when entering the manor, perhaps that is why I did not see the crash with the GoG executable. I will check that.

perrelle avatar Apr 07 '24 18:04 perrelle

No crash but the portrait appears as white on the GoG version.

perrelle avatar Apr 07 '24 18:04 perrelle