Selecting a map in multiplayer mode crashes the game

Bug #1385859 reported by SirVer
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Fix Released
Critical
Unassigned

Bug Description

Multiplayer -> LAN -> Host a game -> "Map" -> doubleclick on any map crashes the game:

Application Specific Information:
abort() called
terminating with uncaught exception of type ImageNotFound: [/Users/sirver/Desktop/Programming/cpp/widelands/bzr_repo/src/graphic/image_io.h:34] Image not found:

Tags: regression

Related branches

Revision history for this message
SirVer (sirver) wrote :

The immediate crash is fixed in r7225.

The problem was code like this:

char* b;
b = boost::format(...).str().c_str();

the problem is that the call to str() will create a std::string() that is then immediately destroyed again. The system is free to reuse the memory that c_str() is pointing to again (since it belonged to the deleted std::string()). In some cases it will do that, in some it will not - that is why the crash happens on some systems but not all.

I grepped through the code base ('format.*c_str') and found more cases where this is happening - note that this is no guarantee that fixing all these removes the problem forever, as code like this is not found but is broken too:

const char* b;
{
   std::string a = format().str();
   b = a.c_str();
}
// the data b is pointing to is undefined here and should not be used.

But the easily greppable cases must be fixed quickly.

GunChleoc (gunchleoc)
Changed in widelands:
assignee: nobody → GunChleoc (gunchleoc)
status: Confirmed → In Progress
GunChleoc (gunchleoc)
Changed in widelands:
status: In Progress → Fix Committed
GunChleoc (gunchleoc)
Changed in widelands:
assignee: GunChleoc (gunchleoc) → nobody
GunChleoc (gunchleoc)
Changed in widelands:
status: Fix Committed → Fix Released
Revision history for this message
GunChleoc (gunchleoc) wrote :

Fixed in build19-rc1.

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.