OOS error in events

Issue #235 invalid
joseasoler repo owner created an issue

For many time we have been getting some random late game OOS errors for which I have failed to find a cause. We got another one recently while playtesting 0.5.0 "prealpha". This time I suspected events, so I added some additional EVENT_DEBUG logBBAIs in many places of the event code. The extra debugging is attached to this issue as a diff file against the HEAD of ExtraModMod. The BBAILogs, OOSLogs and SynchLogs are included in the attached rar file, but the interesting ones are the BBAILogs. In these logs we can see the cause of the first difference; for one of the players EVENTTRIGGER_HELL_PORTAL is being initialized and some random values are calculatd, while for the other this is not being done. Since this event trigger includes a python prerrequisite, and the python prerrequisite is checked before the calculation of the mentioned random values, my guess is that the python prerrequisite was false for one of the players and for the other it was true. For that prerequisite, we have the following python code:

def canTriggerHellPortalCity(argsList):
    # TODO: This should cause an error...
    eTrigger = argsList[0]
    ePlayer = argsList[1]
    iCity = argsList[2]
    pPlayer = gc.getPlayer(ePlayer)
    pCity = pPlayer.getCity(iCity)
    if pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL'):
        if pCity.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_DEMONIC_CITIZENS')) == 0:
            return True
        return False
    return False

Besides the susipicious TODO comment at the beginning of the trigger, I also wonder if the argsList assignation of the beginning is correct, as other events get the player in the following way:

def CanDoNecroCannibalism2 (argsList):
    iEvent = argsList[0]
    kTriggeredData = argsList[1]
    pPlayer = gc.getPlayer(kTriggeredData.ePlayer)

I'm wondering if canTriggerHellPortalCity is using some wrong value for ePlayer such as for example current player in the computer instead of the event player. This may not be a good guess, as many other event trigger prerrequisites get those values in thesame way than canTriggerHellPortalCity.

The attached savegame has been created with revision 007619803755, and it can be used to reproduce the issue.

Comments (5)

  1. joseasoler reporter

    We played a test game with python prerequisites disabled via a quick hack in the DLL. After nearly 300 turns, we had no OOS errors.

  2. lfgr

    Comments so far:

    The argsList thing is correct, as this is a PythonCanDoCity callback for an EventTrigger.

    The comment is from me (0b1088f), and I think I also didn't consider the difference between PythonCanDo and PythonCanDoCity, so it's wrong.

    I created an issue to deal with all the confusion.

  3. lfgr

    I tested your savegame. First I the python exception relating to mobius witches you fixed a bit later. I fixed it manually and got no OOS.

  4. joseasoler reporter

    Prior to posting this, I fixed the mobius witches error locally in all PCs and tried to reproduce the OOS, with success. You may need a few turns to reproduce it. The information posted in the issue was obtained with this fixed version.

  5. joseasoler reporter

    While OOS errors happened quite frequently before fixing 9028aec, they no longer happen after that revision. I think that I was wrong and this issue was caused by random memory leaks instead.

  6. Log in to comment