endless loop in RealFSImpl::EnsureDirectoryExists(

Bug #583774 reported by cghislai
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Fix Released
Medium
Nicolai Hähnle

Bug Description

i found an endless loop in RealFSImpl::EnsureDirectoryExists, found at io/filesystem/disk_filesystem.cc:297 at revision 5348.

The issue is that the condition (it != std::string::npos) in the while loop at line 307 is always true as the value of it is incremented after the call to std::string.find.

I suggest replacing that loop with :

              while (it < dirname.size()) {
                        it = dirname.find('/', it);
                        if (it == std::string::npos) {
                                break;
                        }
                        EnsureDirectoryExists(dirname.substr(0, it));
                        ++it; //make sure we don't keep finding the same directories
                }

That worked for me, but there might be a directories issue that caused this. Ill check that after 1 or 2 games :)

Regards,

Charly

Related branches

Nicolai Hähnle (nha)
Changed in widelands:
status: New → Confirmed
assignee: nobody → Nicolai Hähnle (nha)
Revision history for this message
Nicolai Hähnle (nha) wrote :

There is definitely a problem in that code, though I'm suspicious about your fix. The problem is that if dirname does not end in a slash, e.g. dirname == "foo/bar", then your code will only create "foo", but not "foo/bar". Also, the way the recursive call to EnsureDirectoryExists works makes me really, really uneasy. I'm going to try a different approach.

Revision history for this message
Nicolai Hähnle (nha) wrote :

I've got a proposed fix now, though while working on that fix I also ran into some problems with ~/.widelands creation. Some feedback on the linked branch / merge request would be nice ;)

Changed in widelands:
status: Confirmed → In Progress
importance: Undecided → Medium
Revision history for this message
Nicolai Hähnle (nha) wrote :

Should be fixed in rev5358 of trunk

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

Released in build16-rc1

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.