segmentation fault - AI building enhancement

Bug #1344288 reported by TiborB
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Fix Released
Medium
TiborB

Bug Description

I just encountered a crash, I run the game (AI-only game) under gdb so I collected some information:

Program received signal SIGSEGV, Segmentation fault.
0xb7b7a024 in std::string::c_str() const () from /usr/lib/i386-linux-gnu/libstdc++.so.6
(gdb) bt
#0 0xb7b7a024 in std::string::c_str() const () from /usr/lib/i386-linux-gnu/libstdc++.so.6
#1 0x08b46283 in DefaultAI::check_productionsites (this=0xbef6d80, gametime=370560) at /var/widelands/tibor-ai5/src/ai/defaultai.cc:2075
#2 0x08b3f478 in DefaultAI::think (this=0xbef6d80) at /var/widelands/tibor-ai5/src/ai/defaultai.cc:207

(gdb) frame 1
#1 0x08b46283 in DefaultAI::check_productionsites (this=0xbef6d80, gametime=370560) at /var/widelands/tibor-ai5/src/ai/defaultai.cc:2075
2075 BuildingObserver& en_bo = get_building_observer(bld.name().c_str());

the portion of code:

2072 // Only enhance buildings that are allowed (scenario mode)
2073 if (player_->is_building_type_allowed(enhancement)) {
2074 const Building_Descr& bld = *tribe_->get_building_descr(enhancement);
2075 BuildingObserver& en_bo = get_building_observer(bld.name().c_str());

I cannot repeat the crash, but I encountered the same crash before. Frequency is like once in 100 hours of gameplay. I may insert some printfs to find out at least what buildings are considered for upgrade and wait for next crash...

Tags: ai crash

Related branches

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

>I cannot repeat the crash, but I encountered the same crash before.

Does it crash in the replay, or does that stop just before?

Changed in widelands:
importance: Undecided → Medium
tags: added: computerplayer crash
Revision history for this message
TiborB (tiborb95) wrote :

Well, I did not try, and now I dont know which game it was. I will next time...

Revision history for this message
TiborB (tiborb95) wrote :

I found the reason, basically two lines are relevant

const Building_Index enhancement = site.site->descr().enhancement();
if (player_->is_building_type_allowed(enhancement)) {

The problem was that if there was no enhancement to a building possible, first line returned INVALID_INDEX, and now it is bit funny, player_->is_building_type_allowed(INVALID_INDEX) returned true and algorithm went on as if INVALID_INDEX was real building.

I will commit a fix in tibor-ai5 branch if nobody minds

TiborB (tiborb95)
Changed in widelands:
assignee: nobody → Tibor Bamhor (tiborb95)
Revision history for this message
TiborB (tiborb95) wrote :

Fixed with comiting tibor-ai5 to trunk (r7204)

Changed in widelands:
status: New → Fix Committed
Revision history for this message
GunChleoc (gunchleoc) wrote :

I have now linked the branch to this bug report ;)

Changed in widelands:
milestone: none → build19-rc1
GunChleoc (gunchleoc)
tags: added: ai
removed: computerplayer
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.