Saving a game a second time causes a crash

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

Bug Description

r8506 (debug and asan)

1. Start a new game
2. Save the game
3. Save the game again

Result:

Thread 1 "widelands" received signal SIGSEGV, Segmentation fault.
0x0000555557126c0e in FileSystem::fs_filename (p=0x613076800150 "") at ../src/io/filesystem/filesystem.cc:312
312 while (*p != '\0') {

Backtrace attached

Tags: crash

Related branches

Revision history for this message
kaputtnik (franku) wrote :
Revision history for this message
kaputtnik (franku) wrote :
Revision history for this message
GunChleoc (gunchleoc) wrote :

I think I changed something in the fs class from char* to std::string recently.

Revision history for this message
kaputtnik (franku) wrote :

I have recompiled from scratch, deleting the build directory and without ASAN.

I save the first time with name 'test'. When i want to save the second time some unrecognized characters are shown in the save dialog. See at the bottom of the attached image.

Revision history for this message
kaputtnik (franku) wrote :

When i hit save the file is really saved with a bad name:

~/.widelands/save
$:> ls -l
insgesamt 100
-rw-r--r-- 1 kaputtnik users 337 28. Sep 02:10 campvis
-rw-r--r-- 1 kaputtnik users 47087 27. Nov 21:28 test.wgf
-rw-r--r-- 1 kaputtnik users 47283 27. Nov 21:30 ''$'\260''t'$'\323\336''EV.wgf'

Really critical because such a file couldn't be easily deleted.

Changed in widelands:
importance: Undecided → Critical
Revision history for this message
Jukka Pakarinen (flegu) wrote :

I can avoid the problem by doing the following change. I used trunk 8508.

=== modified file 'src/wui/game_main_menu_save_game.cc'
--- src/wui/game_main_menu_save_game.cc 2017-11-05 19:59:33 +0000
+++ src/wui/game_main_menu_save_game.cc 2017-11-28 20:50:38 +0000
@@ -132,8 +132,8 @@
        ok_.set_enabled(load_or_save_.table().selections().size() == 1);
        load_or_save_.delete_button()->set_enabled(load_or_save_.has_selection());
        if (load_or_save_.has_selection()) {
- const SavegameData& gamedata = *load_or_save_.entry_selected();
- filename_editbox_.set_text(FileSystem::filename_without_ext(gamedata.filename.c_str()));
+ std::unique_ptr<SavegameData> gamedata = load_or_save_.entry_selected();
+ filename_editbox_.set_text(FileSystem::filename_without_ext(gamedata->filename.c_str()));
        }
 }

Revision history for this message
GunChleoc (gunchleoc) wrote :

#6 looks good to me.

Revision history for this message
Jukka Pakarinen (flegu) wrote :

I'm quite busy now to test this. Maybe the next weekend. If someone have more time...

Revision history for this message
GunChleoc (gunchleoc) wrote :

Since this is critical, I'll make a branch. Thanks for your investigation!

Changed in widelands:
milestone: none → build20-rc1
assignee: nobody → GunChleoc (gunchleoc)
status: New → In Progress
Revision history for this message
kaputtnik (franku) wrote :

Jukka, it would be nice if you could provide a branch if you think you fixed a bug. So it is easier to test by just downloading and compiling, at least for me ;-)

Thanks for your work!

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

Fixed in build20-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.