Opened 3 years ago

Closed 3 years ago

#12617 closed defect (fixed)

AGOS: Deadlock when shutting down game, at least with the MT-32 emulator

Reported by: eriktorbjorn Owned by: athrxx
Priority: normal Component: Engine: AGOS
Version: Keywords:
Cc: Game:

Description

I've noticed several times that when I shut down an AGOS games that uses the MT-32 emulator, it deadlocks. Of course, such problems can be tricky to debug. I think the sequence of events goes like this:

  1. AGOS::~MidiPlayer() is called, but has not yet had the time to lock _mutex.
  2. The audio thread calls AGOS::MidiPlayer::onTimer(), which has not yet had the time to lock _mutex.
  3. ~MidiPlayer() locks _mutex, leaving onTimer() waiting.
  4. ~MidiPlayer() calls _driver->close()
  5. MidiDriver_MT32::close() calls _mixer->stopHandle() which never terminates.

I think stopHandle() may be waiting for readBuffer() to finish, but it never does because onTimer() is blocked. But I'm not quite sure.

I've seen this happen with the DOS talkie version of Simon the Sorcerer 1, and I also had it lock up with Elvira 2, probably for the same reason.

Change History (1)

comment:1 by athrxx, 3 years ago

Owner: set to athrxx
Resolution: fixed
Status: newclosed

That one should be fixed...

Note: See TracTickets for help on using tickets.