Crash when expedition port is destroyed while wares are unloaded

Bug #1387801 reported by wl-zocker
24
This bug affects 2 people
Affects Status Importance Assigned to Milestone
widelands
Fix Released
High
Unassigned

Bug Description

This issue was found by dax831 in our forum [1] in build 18, but it still happens in r7237 (both on Win7).

To reproduce either use the savegame from the forum (build 18), it crashes after some seconds. The reason is that the port space north-west to the starting viewpoint is conquered by the red player and the construction site is destroyed.
You can also use the attached savegame (r7237) and start building a port. While there are still wares on the ship, destroy the construction site. The game crashes. This does not happen when all wares and the builder have been unloaded (and the ship drives away) before the construction site is destroyed.

In both cases, I am back on my desktop. There is no error message (or anything useful in stdout/stderr).

[1] https://wl.widelands.org/forum/topic/1570/

Revision history for this message
wl-zocker (wl-zocker) wrote :
Revision history for this message
Hans Joachim Desserud (hjd) wrote :

Thanks for reporting this.

I was able to reproduce this issue based on the attached save game and your instructions in r7240. I got the attached backtrace on Ubuntu.

I guess the problem is that the ship is still trying to unload its cargo, but the wares have no where to go anymore. (I wonder whether this can potentially also be triggered if you destroy the target port while the ship is unloading when doing normal ware transportation.)

Changed in widelands:
importance: Undecided → Medium
status: New → Triaged
tags: added: savegame
Revision history for this message
Hans Joachim Desserud (hjd) wrote :
SirVer (sirver)
Changed in widelands:
milestone: none → build19-rc1
importance: Medium → High
Revision history for this message
TiborB (tiborb95) wrote :

Well, I can imagine the change in code: if a port is not there, do not unload wares, but set itself to EXP_WAITING state and send a message 'Port is probably gone, waiting for new orders'.

But entire shipping stuff is quite complicated, I do not understand it fully....

Anyway, if nobody else, I will look at it....

Revision history for this message
wl-zocker (wl-zocker) wrote :

Some of the wares might have been unloaded, and with the remaining wares, no other port can be built. The ship would therefore have to return to the starting/nearest port (similar to "Cancel expedition"). There it could either
- be refilled so that the player can start another expedition
- be emptied.

I prefer option 1, because the player might want to build a port somewhere else. If he does not want that, cancelling the expedition is probably faster than emptying the ship first and then starting a new expedition.

Revision history for this message
TiborB (tiborb95) wrote :

I think no wares are unloaded at all. 'assert(baim)' throws an exemption before transferring of wares starts.

Revision history for this message
wl-zocker (wl-zocker) wrote :

Start building a port. Some wares will be unloaded because the game does not know what is going to happen. Destroy the in-construction port. The already unloaded wares are lost, the others remain on the ship. For example, you now have a builder, a quartz, a diamond and two gold on the ship, which is not enough to build another port. When the ship attemps to unload the *next* ware, the crash occurs.

Revision history for this message
TiborB (tiborb95) wrote :

I believed that all wares are unloaded at once, all right then...

Revision history for this message
TiborB (tiborb95) wrote :

I am getting crash on current trunk:

Game: Writing Preload Data ...
Program received signal SIGSEGV, Segmentation fault.
0x08b60a2d in Widelands::GamePreloadPacket::write (this=0xbfffd974, fs=..., game=...)
    at /var/widelands/trunk/src/game_io/game_preload_packet.cc:117
117 s.set_int("gametype", static_cast<int32_t>(game.game_controller()->get_game_type()));

is it known problem?

Revision history for this message
Tino (tino79) wrote :

Yes, i experience crashes at the same code point.
I've opened a bug report: https://bugs.launchpad.net/widelands/+bug/1388829

Revision history for this message
TiborB (tiborb95) wrote :

I achieved something. Ships returns to a port and unloads, but warehouse window gets into inconsistent state.

Other alternative is that ship stays where it was and user will have to manuali click "cancel expedition". If he instead continues with scouting and tries to build a port elsewhere, port is not finished and the ship is again in some inconsistent status.

Revision history for this message
wl-zocker (wl-zocker) wrote :

> Ships returns to a port and unloads, but warehouse window gets into inconsistent state.

There is bug 1191556. Maybe related?

> Other alternative is that ship stays where it was and user will have to manuali click "cancel expedition".

Since the ship cannot do anything else, I consider this micro-management. Better send a message that there were problems and the ship will return to a port.

> If he instead continues with scouting and tries to build a port elsewhere, port is not finished and the ship is again in some inconsistent status.

I think such a case (unfinished port) is very difficult to handle, therefore I did not mention this option.

Revision history for this message
TiborB (tiborb95) wrote :

wl-zocker, I think your description in https://bugs.launchpad.net/widelands/+bug/1191556/comments/4 fits.

Except this, I think I have it, a ship returns to port and unloads properly.

I have it in seafaring-ai as by now (not pushed up by now), because trunk is broken anyway so it would not be test-able in I created new branch from it.

Revision history for this message
SirVer (sirver) wrote :

There are already a bunch of tests for seafaring, this sounds like it is easily testable too. That should make fixing it easier.

Revision history for this message
TiborB (tiborb95) wrote :

should be merged as a part of seafaring-ai branch - revision 7399

Changed in widelands:
status: Triaged → Fix Committed
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.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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