UltraStar-Deluxe / USDX

The free and open source karaoke singing game UltraStar Deluxe, inspired by Sony SingStarâ„¢
https://usdx.eu
GNU General Public License v2.0
832 stars 160 forks source link

[Windows] USDX crashes if starting twice at the 'same' time #99

Closed RattleSN4K3 closed 7 years ago

RattleSN4K3 commented 8 years ago

By running USDX twice, at least 1 crashes. (it happend by running ultrastardx.exe but haven't noticed a running process, the app was still loading in the background, started the exe again).

A basic CMD script; crashing EAAccessVoliation (UMain:277 "DataBase.Destroy":

@echo off
start ultrastardx
call :Wait 100
start ultrastardx
goto :eof

:Wait
if %script_no_wait% == 0 @ping 1.1.1.1 -n 1 -w %1 > nul
goto :EOF

Another fast test crashing sometimes with a INI file creation error.

@echo off
start ultrastardx
start ultrastardx
basisbit commented 8 years ago

this is what you get when you try writing to a sqlite file from two different applications. this is not a bug but instead caused by design decision.

RattleSN4K3 commented 8 years ago

It's not by design. It's a bug, That's what I wrote. It checks for an instance with the same window title, but the window title is changed during the loading phase. This is bug #1.

The next thing which is bugging/crashing is this:

  try
    //...
    if Platform.TerminateIfAlreadyRunning(WindowTitle) then
      Exit; 

      //...
      DataBase := TDataBaseSystem.Create;

  finally
      DataBase.Destroy();

Finally section will always be called even if you exit a block. DataBase is trying to destroy itself when the pointer/instance is not existing -> AccessViolation / null pointer crash. Bug #2.

The next which can happen, but program pass the Platform.TerminateIfAlreadyRunning check, by loading the INI file and saving it. I haven't checked what the origin is, but it happened al least like 5 times (using debug or game.exe).

There are additional cases in the finally catch which result in a crash. Database is the first one which is catched by the outer Main try-catch which quits the program.

RattleSN4K3 commented 8 years ago

In relation: UltraStar-Deluxe/mirror@162908ecfe023e2a261ccfaa78fec8acce1a7ecd

That change does break the check for another instance (due to checking for a process with the same window title)