diasurgical / devilutionX

Diablo build for modern operating systems
Other
8.08k stars 796 forks source link

x64-Debug Crashes when Loading/New Character #1983

Closed NiteKat closed 3 years ago

NiteKat commented 3 years ago

Important information Windows 10 / de3f3062 of master / compiled myself using Visual Studio 2019

Describe The x64-Debug build crashes when selecting to load a saved character, or creating a new character. x64-Release build runs fine.

To Reproduce Steps to reproduce the behavior:

  1. Build commit de3f3062 using Visual Studio 2019 as x64-Debug
  2. Open the built devilutionx.exe
  3. Go to single player
  4. Select a character and load game OR make a new character and select difficulty
  5. Watch game crash

Expected behavior The game should load the saved character

Additional context Per Visual Studio, crash happens on line 5432 of SDL_malloc.c. Call stack:

ntdll.dll!RtlSizeHeap() Unknown
AcLayers.dll!NS_FaultTolerantHeap::APIHook_RtlFreeHeap(void *,unsigned long,void *) Unknown
ucrtbase.dll!_free_base()   Unknown
SDL2.dll!SDL_free_REAL(void * ptr) Line 5432    C
SDL2.dll!SDL_FreePalette_REAL(SDL_Palette * palette) Line 742   C
SDL2.dll!SDL_SetPixelFormatPalette_REAL(SDL_PixelFormat * format, SDL_Palette * palette) Line 695   C
SDL2.dll!SDL_SetSurfacePalette_REAL(SDL_Surface * surface, SDL_Palette * palette) Line 215  C
SDL2.dll!SDL_FreeSurface_REAL(SDL_Surface * surface) Line 1333  C
devilutionx.exe!dvl::RenderUTF8_Solid_Wrapped(_TTF_Font * font, const char * text, SDL_Color fg, unsigned int wrapLength, const int x_align) Line 181   C++
devilutionx.exe!dvl::DrawTTF(const char * text, const SDL_Rect & rectIn, int flags, const SDL_Color & text_color, const SDL_Color & shadow_color, dvl::TtfSurfaceCache * * render_cache) Line 46    C++
devilutionx.exe!dvl::`anonymous namespace'::Render(dvl::UiText * ui_text) Line 695  C++
devilutionx.exe!dvl::`anonymous namespace'::RenderItem(dvl::UiItemBase * item) Line 781 C++
devilutionx.exe!dvl::UiRenderItems(std::vector<dvl::UiItemBase *,std::allocator<dvl::UiItemBase *>> items) Line 907 C++
devilutionx.exe!dvl::`anonymous namespace'::DialogLoop(std::vector<dvl::UiItemBase *,std::allocator<dvl::UiItemBase *>> items, std::vector<dvl::UiItemBase *,std::allocator<dvl::UiItemBase *>> renderBehind) Line 250  C++
devilutionx.exe!dvl::UiOkDialog(const char * text, const char * caption, bool error, std::vector<dvl::UiItemBase *,std::allocator<dvl::UiItemBase *>> renderBehind) Line 280    C++
devilutionx.exe!dvl::UiErrorOkDialog(const char * text, const char * caption, bool error) Line 292  C++
devilutionx.exe!dvl::MsgBox(const char * pszFmt, char * va) Line 29 C++
devilutionx.exe!app_fatal(const char * pszFmt, ...) Line 65 C++
devilutionx.exe!dvl::InitQol() Line 73  C++
devilutionx.exe!dvl::start_game(dvl::interface_mode uMsg) Line 237  C++
devilutionx.exe!dvl::run_game_loop(dvl::interface_mode uMsg) Line 305   C++
devilutionx.exe!StartGame(int bNewGame, int bSinglePlayer) Line 393 C++
devilutionx.exe!dvl::mainmenu_init_menu(int type) Line 46   C++
devilutionx.exe!dvl::mainmenu_single_player() Line 63   C++
devilutionx.exe!mainmenu_loop() Line 153    C++
devilutionx.exe!DiabloMain(int argc, char * * argv) Line 638    C++
devilutionx.exe!SDL_main(int argc, char * * argv) Line 35   C++
devilutionx.exe!main_getcmdline() Line 71   C
NiteKat commented 3 years ago

Think I figured it out. An error message is supposed to have displayed, but instead the app just crashed so it took a moment. It looks like the build puts devilution.mpq into the release folders, but not the debug folders. Is this by design?

AJenbo commented 3 years ago

Is this by design?

No. What error message is it trying to show?

NiteKat commented 3 years ago

Based on the call stack, it looked like the one for not being able to load devilution UI elements, which led me to realize devilution.mpq was not in the debug folder. But to be honest, not sure if it was added to release folder by the build process either, or if I added it at some point (though I chose Rebuild All option, so I think that would clear it out of the folders...? But maybe not. I'll try deleting the build folders and building again and report back.

qndel commented 3 years ago

works fine for me

ephphatha commented 3 years ago

I haven't been able to reproduce this crash on windows 10 with msvc2022 or 2019 using either the target commit or latest master, even when commenting out the code that loads devilutionx.mpq and forcing the code that triggers that error dialog to run.

The error dialog results from the app_fatal call in qol/monhealthbar.cpp InitMonsterHealthBar() if devilutionx_mpq isn't a valid handle. This currently renders as expected (...well, with an invisible cursor on de3f306). Maybe it only happens with a specific version of SDL?