View Issue Details

IDProjectCategoryView StatusLast Update
0001848Spring engineUnit Scriptingpublic2010-02-22 01:36
Reporterkmcguire Assigned Tohoijui  
PrioritynormalSeveritycrashReproducibilityalways
Status resolvedResolutionno change required 
Product Version0.81.1.3 
Summary0001848: skirmishAiCallback_UnitDef_MoveData_* Access Violation
DescriptionClb_UnitDef_MoveData_getDepthMod, -- UnitDefId=316
Clb_UnitDef_MoveData_getMoveType, -- UnitDefId=316
Clb_UnitDef_MoveData_isSubMarine, -- UnitDefId=316

Loading an AI DLL (starting the game from the command line using spring.exe) and clicking the test button (at top) will produce a crash from an access violation. Somewhere inside skirmishAiCallback_UnitDef_MoveData_getTerrainClass a instruction tries to access memory that does not exist:

IF, you call the function with the arguments __stdcall(int32_t=1, int32_t=316).

This also happens with a few other functions and maybe others. This could be a problem on my machine, or a mistake that I am making.
Additional Information/*
        This should be sufficient to produce the crash.
*/
extern "C" __declspec(dllexport) int __stdcall init(int teamId, const struct SSkirmishAICallback* callback)
{
    callback->Clb_UnitDef_MoveData_isSubMarine(1, 316);
    return 0;
}


extern "C" int __declspec(dllexport) __stdcall handleEvent(int teamId, int topic, const void* data)
{
    return 0;
}
TagsNo tags attached.
Attached Files
infolog.txt (Attachment missing)
Checked infolog.txt for Errors

Activities

hoijui

2010-02-21 20:57

reporter   ~0004675

EXPORT(int) init(int teamId, const struct SSkirmishAICallback* callback)
{
    bool isMDAvail = callback->Clb_UnitDef_0AVAILABLE0MoveData(teamId, 316);
    if (isMDAvail) {
        callback->Clb_UnitDef_MoveData_getDepthMod(teamId, 316);
        callback->Clb_UnitDef_MoveData_getMoveType(teamId, 316);
        callback->Clb_UnitDef_MoveData_isSubMarine(teamId, 316);
    }
    return 0;
}

kmcguire

2010-02-21 23:11

reporter   ~0004676

Thank you for the solution. The rest is for you guys to consider if it is a bug or not. I am okay either way. I got it figured out now.

hoijui

2010-02-22 01:36

reporter   ~0004677

:-)
a crash through this can only be run into with a bug in an AI Interface or Wrapper (assuming nobody writes a pure C AI). runtime guarding against it would mean overhead (even doh little, of course).
i added assert(s) in the functions you mentioned (in pureint branch).

Issue History

Date Modified Username Field Change
2010-02-21 17:15 kmcguire New Issue
2010-02-21 17:15 kmcguire File Added: infolog.txt
2010-02-21 20:57 hoijui Note Added: 0004675
2010-02-21 23:11 kmcguire Note Added: 0004676
2010-02-22 01:36 hoijui Note Added: 0004677
2010-02-22 01:36 hoijui Status new => resolved
2010-02-22 01:36 hoijui Resolution open => no change required
2010-02-22 01:36 hoijui Assigned To => hoijui