Game crashed in Sound_Handler

Bug #542163 reported by Jari Hautio
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Fix Released
High
Jari Hautio

Bug Description

This happened originally in windows when I was porting the code to compile on visual studio.

The game crashed after few minutes to a threading bug in sound_handler.cc:328:
       const std::map<uint32_t, std::string>::const_iterator active_fx_end =
               m_active_fx.end();
       for
               (std::map<uint32_t, std::string>::const_iterator it =
                m_active_fx.begin();
                it != active_fx_end;
                ++it)
       {
       // Crashed here! it is not valid and m_active_fx is empty.
       // Probably threading problem with erase() in handle_channel_finished()
               if (it->second == fx_name) {

iterator is bad, m_active is empty but active_fx_end is != it. Looks
like a threading bug. Sound_Handler::m_active_fx must be protected by
a lock because handle_channel_finished() erases items from another
thread.

Confirmed later that m_active_fx map is actively accessed from multiple threads.

Jari Hautio (jarih)
Changed in widelands:
status: New → In Progress
assignee: nobody → Jari Hautio (jarih)
Revision history for this message
Jari Hautio (jarih) wrote :

Fix with SDL_mutexes attached.
Tested on 32-bit windows and linux builds with cmake.

Nasenbaer (nasenbaer)
Changed in widelands:
importance: Undecided → High
milestone: none → build15
Revision history for this message
Nasenbaer (nasenbaer) wrote :

Your patch works fine for me Jari!
Will commit it to trunk!

Nasenbaer (nasenbaer)
Changed in widelands:
status: In Progress → Fix Committed
Revision history for this message
SirVer (sirver) wrote :

Released in build15 rc2

Changed in widelands:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.