Opened 7 years ago

Last modified 7 years ago

#4502 new defect

ScummVM won't quit if error() is called in a timer callback

Reported by: eriktorbjorn Owned by:
Priority: normal Component: --Unset--
Keywords: Cc:
Game:

Description

Current SVN snapshot.

If ScummVM calls error() inside a timer callback (e.g. in some parts of Digital iMUSE), ScummVM won't quit no matter (almost) what you do. I believe this is because when OSystem_SDL::quit() deletes _timer, it has to wait for the timer class to release its mutex. And that won't happen since we're still inside the timer callback.

I'm not sure how to fix this.

Ticket imported from: #2830903. Ticket imported from: bugs/4502.

Change History (2)

comment:1 Changed 7 years ago by fingolfin

Nasty. Doesn't the issue run deeper, though? If we error(), we open a GUI console. This is now *inside* the timer callback, which thus never returns. That sounds like it might cause bad things, too...

So, how about this approach: Modify OSystem_SDL::quit() to detect whether we are in the time handler. If we are, don't bother to cleanly update anything, just quit right away (using "exit(1)" maybe). That should solve at least the "doesn't quit" issue, at least for the SDL backend.

comment:2 Changed 7 years ago by eriktorbjorn

I was focusing only on the problem I could see with my own eyes, but it's quite possible that - as you say - the problem runs much deeper than that, so that when the GUI is running, it's already too late.

The downside to quitting immediately is of course that this may make it harder to diagnose problems with corrupt audio files in games that use Digital iMUSE. (Something that seems to happen surprisingly often, for reasons I do not understand.) But perhaps those parts of the code could be rewritten to not use error() directly.

Note: See TracTickets for help on using tickets.