bugFreeciv - Bugs: bug #18461, crash using lua function civil_war...

 
 
Show feedback again

bug #18461: crash using lua function civil_war (in ai_plr_data_get() [aidata.c::310]: assertion 'ai->phase_initialized' failed.)

Submitted by:  Matthias Pfafferodt <syntron>
Submitted on:  Sat 06 Aug 2011 10:34:57 PM UTC  
 
Category: aiSeverity: 3 - Normal
Priority: 5 - NormalStatus: In Progress
Assigned to: NoneOpen/Closed: Open
Release: 2.3.99 (svn20069)Operating System: None
Planned Release: 2.4.0

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Wed 10 Aug 2011 06:19:38 AM UTC, comment #7:

I'm not 100% sure about the patch - can't be as I did only test my error case. Here it did remove the crash and, furthermore, did not add any other. As I see it the following work flow is done:

srv_running()
- begin_turn()
-- new initialisation to ai/adv phase
- loop (phases)
-- begin_phases()
--- initialisation to ai/adv phase; if initialised, do nothing
-- (some code)
-- end_phase()
--- end of ai/adv phase
- end (loop phases)
- end_turn()
-- in this function the ai/adv phase can be closed to have the correct count of begin/end; these functions will do nothing at the moment but as you said, would be helpful to read the code

Matthias Pfafferodt <syntron>
Project Member
Tue 09 Aug 2011 09:13:09 PM UTC, comment #6:

Are you sure about the patch? Just by reading it (without checking from source code more context) I notice that you add initialization to one place, but don't remove it from anywhere. Isn't this going to cause double initialization? (If it is, and you have tested this patch without error messages, we are missing important assert)
Also, I don't remember offhand what, but moving the initialization earlier from where it is may cause other problems (I recall that when I last moved it, I put it as early as possible) Some information that it uses is bogus earlier, or something like that. Code comments or old tickets hopefully contain more exact information.

Marko Lindqvist <cazfi>
Project Administrator
Tue 09 Aug 2011 09:01:27 PM UTC, comment #5:

I did read bug #18333 and at least the reason I found is similar. The signal 'turn_started' is called in begin_turn. At that time ai/adv phase is not open for any player. It is initialised in begin_phase() in srv_running(). It crashs on contact to a player which exists before (the new player has the phases initialised).

I did not test any other but the default phase setting. I I remember correctly I never did test the different possibilities of this setting.

Matthias Pfafferodt <syntron>
Project Member
Tue 09 Aug 2011 06:46:36 PM UTC, comment #4:

Is civil war another case where phasemode != simultaneous would cause problems as described in bug #18333?

Marko Lindqvist <cazfi>
Project Administrator
Tue 09 Aug 2011 06:12:43 PM UTC, comment #3:

I did some tests and I do use a unique setting: civil_war() is called via the lua signal 'turn_started'. At the time this signal is raised, neither the advisor nor the AI are initialized. Thus the core dump. The attached patch fixes the error by doing the initialization before ...

Please test ...

(file #13791)

Matthias Pfafferodt <syntron>
Project Member
Tue 09 Aug 2011 09:02:02 AM UTC, comment #2:

Oh, rats.
(Doesn't civil_war() execute mid-turn when you trigger it by taking over a city? Is that already dealt with?)

Jacob Nevins <jtn>
Project Administrator
Tue 09 Aug 2011 06:06:43 AM UTC, comment #1:

civil_war() was designed to be called during turn change (ai phase for all players). Now, it can be executed via a lua function at any time. Thus, the ai phase does not have to be initialized. One possible solution would be to check for this if a civil war occurs. Thus, the ai phase would be initialized for all players, the civil war executed, and after that the ai phase would be closed. Thoughts?

Matthias Pfafferodt <syntron>
Project Member
Sat 06 Aug 2011 10:34:57 PM UTC, original submission:

I'm working on a lua test game. Trying to add the lua function civil_war() I got the following core dump:

The attached savegame can be used to reproduce it. Simply start freeciv as './ser -F -f luatest.sav' and enter start ...

Matthias Pfafferodt <syntron>
Project Member

 

(Note: upload size limit is set to 1024 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #13763:  luatest.sav added by syntron (38kB - application/x-spss-sav)

 

Depends on the following items: None found

Items that depend on this one

Digest:
   patch dependencies.

 

Carbon-Copy List
  • -unavailable- added by cazfi (Posted a comment)
  • -unavailable- added by jtn (Posted a comment)
  • -unavailable- added by syntron (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 10 Aug 2011 06:19:38 AM UTCsyntronStatusReady For Test=>In Progress
    Tue 09 Aug 2011 06:12:43 PM UTCsyntronAttached File-=>Added 20110808-48-initialize-advisor-and-AI-code-before-lua-signal-tur.patch, #13791
      StatusNone=>Ready For Test
    Sat 06 Aug 2011 10:34:57 PM UTCsyntronAttached File-=>Added luatest.sav, #13763
    Show feedback again

    Back to the top


    Powered by Savane 3.1-cleanup