Java AI API: bug SIGSEGV or dirrerent API interface?

Java AI API: bug SIGSEGV or dirrerent API interface?

Here is where ideas can be collected for the skirmish AI in development

Moderators: hoijui, Moderators

playerO1
Posts: 57
Joined: 25 Jun 2014, 15:22

Java AI API: bug SIGSEGV or dirrerent API interface?

Post by playerO1 »

Hello. I'm try write AI, and learn how it work.
I try read UnitDef param and look any mod specification. I using next code, but my Spring engine crash by Segmentation fault (version 94.1, 96.0) where I call function def.getCustomParams():

Code: Select all

public void showUnitDefInfoDebug(UnitDef unit){
    sendTextMsg("Unit info: " + unit.getName()+" humanName: "+unit.getHumanName()+" techLevel: "+unit.getTechLevel()+" defID: "+unit.getUnitDefId(), MSG_DBG_SHORT);
    sendTextMsg("Unit is: AbleToAssist " + unit.isAbleToAssist()+" AbleToMove "+unit.isAbleToMove()+" Assistable "+unit.isAssistable(), MSG_DBG_SHORT);
    sendTextMsg("build: BuildDistance " + unit.getBuildDistance()+", BuildSpeed "+unit.getBuildSpeed()+"; moving speed="+unit.getSpeed(), MSG_DBG_SHORT);
    
    for (Resource res:clb.getResources())
        sendTextMsg("For resource "+res.getName()+" info: "+ 
            " def.getResourceMake(r)" + unit.getResourceMake(res) +
            " def.getMakesResource(r)" + unit.getMakesResource(res) +
            " def.getExtractsResource(r): " + unit.getExtractsResource(res) +
            " def.getTidalResourceGenerator(r): " + unit.getTidalResourceGenerator(res) +
            " def.getWindResourceGenerator(r): " + unit.getWindResourceGenerator(res) +
            " def.getResourceExtractorRange(r): " + unit.getResourceExtractorRange(res) +
            " def.getUpkeep(r): " + unit.getUpkeep(res) +
            " def.getCost(r): " + unit.getCost(res) +
            " def.getStorage(r): " + unit.getStorage(res) +
            "ResourceSumm(+map&mod specific)="+getUnitResoureProduct(unit, res)    , MSG_DBG_ALL);
    List<UnitDef> buildOptions = unit.getBuildOptions();
    for (UnitDef unitDef : buildOptions) {
        sendTextMsg(" build: " + unitDef.getName() + "\t" + unitDef.getHumanName() + "\t" + unitDef.toString() + "\t" + unitDef.hashCode(), MSG_DBG_ALL);
    }
}
...
sendTextMsg("---- UnitDef list (ALL "+modSpecific.allUnitDefs.size()+") ----", FieldBOT.MSG_DBG_ALL);
for (UnitDef def:modSpecific.allUnitDefs) {
    sendTextMsg("ID="+def.getUnitDefId()+" "+def.getName()+" ("+def.getHumanName()+") level "+def.getTechLevel()+" isBuilder="+def.isBuilder(), FieldBOT.MSG_DBG_ALL);
    showUnitDefInfoDebug(def); // some other shows
    sendTextMsg("",FieldBOT.MSG_DBG_ALL);
    if (def.getCustomParams()!=null && !def.getCustomParams().isEmpty()) { // <====SEGMENTATION FAULED in Spring 96, 94.1
        sendTextMsg(" CustomParams:", FieldBOT.MSG_DBG_ALL);
        for (Map.Entry<String, String> params :def.getCustomParams().entrySet()) {
            sendTextMsg(" K:"+params.getKey()+" V:"+params.getValue(), FieldBOT.MSG_DBG_ALL);
        }
    }
}
sendTextMsg("----  ----", FieldBOT.MSG_DBG_ALL);
...
fragment of infolog.txt:

Code: Select all

[f=0000001] Error: Segmentation fault (SIGSEGV) in spring 94.1 (ASIM GML OMP)
[f=0000001] Error: Stacktrace:
[f=0000001] Error: This stack trace indicates a problem with an AI Interface library.
[f=0000001] Error:   <0> ??:?
[f=0000001] Error:   <1> ??:?
[f=0000001] Error:   <2> /lib/x86_64-linux-gnu/libpthread.so.0(+0x10340) [0x7fe13f8c0340]
[f=0000001] Error:   <3> ??:?
[f=0000001] Error:   <4> ??:?
[f=0000001] Error:   <5> [0x7fe0d9011790]
[f=0000001] MetalMakers widget disabled for spectators
[f=0000001] Error: Releasing AI Interface Library from file "/home/user/.spring/engines/94.1/AI/Interfaces/Java/0.1/libAIInterface.so". The call to releaseStatic() returned unsuccessfuly.
[f=0000001] [CCollisionHandler] dis-/continuous tests: 0/106965
[f=0000001] Path cache hits 0 0%
infolog.txt for 96:

Code: Select all

[f=0000000] Initializing PathCache
[f=0000000] Finalizing
[f=0000000] Loaded DecalsDrawer: Legacy
[f=0000000] Connection attempt from ME
[f=0000000]  -> Version: 96.0
[f=0000000]  -> Connection established (given id 0)
[f=0000000] Player ME finished loading and is now ingame
[f=0000000] GameID: 06eaab530e06a468d0615d981cdf4421
[f=0000000] Error: Segmentation fault (SIGSEGV) in spring 96.0
[f=0000000] Error: Stacktrace for Spring 96.0:
[f=0000000] Error: This stack trace indicates a problem with an AI Interface library.
[f=0000000] Error:   <0> ??:?
[f=0000000] Error:   <1> ??:?
[f=0000000] Error:   <2> /lib/x86_64-linux-gnu/libpthread.so.0(+0x10340) [0x7fd590508340]
[f=0000000] Error:   <3> ??:?
[f=0000000] Error:   <4> ??:?
[f=0000000] Error:   <5> [0x7fd521011790]
[f=0000000] Error: [ErrorMessageBox][1] msg="Spring has crashed:
Segmentation fault (SIGSEGV).

A stacktrace has been written to:
  /home/user/.config/spring/infolog.txt" IsMainThread()=1 fromMain=0
[f=0000000] Error: [ErrorMessageBox][2]
[f=0000000] [SpringApp::ShutDown][1]
[f=0000000] [ThreadPool::SetThreadCount][1] #wanted=0 #current=3
[f=0000000] [ThreadPool::SetThreadCount][2] #threads=0
[f=0000000] [SpringApp::ShutDown][2]
[f=0000000] [~CGame][1]
[f=0000000] [~CGame][2]
[f=0000000] [~CGame][3]
[f=0000000] [~CGame][4]
[f=0000000] [~CGame][5]
[f=0000000] Team0 (PeaceBOT) has been decommissioned
[f=0000000] Team1 (NullAI) lived up to their reputation
[f=0000000] Team2 () has been played out
[f=0000000] Team3 () couldn't resist pushing the red button
[f=0000000] Error: Releasing AI Interface Library from file "/home/user/.config/spring/AI/Interfaces/Java/0.1/libAIInterface.so". The call to releaseStatic() returned unsuccessfuly.
[f=0000000] [~CGame][6]
[f=0000000] Red_UI_Framework>> last processed widget was "Red Tooltip"
[f=0000000] Red_Drawing>> last processed widget was "Red Tooltip"
[f=0000000] [~CGame][7]
[f=0000000] [~CGame][8]
[f=0000000] [CCollisionHandler] dis-/continuous tests: 0/0
[f=0000000] [~CGame][9]
[f=0000000] [~CGame][10]
[f=0000000] [~CPathCache(32x32)] cacheHits=0 hitPercentage=0% numHashColls=0 maxCacheSize=0
[f=0000000] [~CPathCache(32x32)] cacheHits=0 hitPercentage=0% numHashColls=0 maxCacheSize=0
[f=0000000] [~CPathCache(128x128)] cacheHits=0 hitPercentage=0% numHashColls=0 maxCacheSize=0
[f=0000000] [~CPathCache(128x128)] cacheHits=0 hitPercentage=0% numHashColls=0 maxCacheSize=0
[f=0000000] Statistics for RectangleOptimizer: 0%
[f=0000000] Statistics for RectangleOptimizer: 0%
[f=0000000] [~CGame][11]
[f=0000000] [~CGame][12]
[f=0000000] [~CGame][13]
[f=0000000] [~CGame][14]
[f=0000000] [~CGame][15]
[f=0000000] [~CGameServer][1]
[f=0000000] [~CGameServer][2]
[f=0000000] [~CGame][16]
[f=0000000] [Sound] [~CSound][1] soundThread=0x21f4790
[f=0000000] [Sound] [~CSound][2]
[f=0000000] [Sound] [~CSound][3]
[f=0000000] [~CGame][17]
[f=0000000] [SpringApp::ShutDown][3]
[f=0000000] [SpringApp::ShutDown][4]
[f=0000000] Statistics for local connection:
Maybe I use wrong Java API? Where I can see last version of Java API for last Spring Engine?
Last edited by playerO1 on 01 Jul 2014, 16:58, edited 1 time in total.
playerO1
Posts: 57
Joined: 25 Jun 2014, 15:22

Re: Java AI API: bug SIGSEGV or dirrerent API interface?

Post by playerO1 »

I read comment for AI API from documentation on http://spring.abma.de/doc-Interface-JavaOO/. And this documentation not full and sometime is not correctly. I found that call function on class Economy "sendResource(...)" and "sendUnits(...)" not take effect if call this function not from "update(int frame)". (if call "sendResource" from "message(int player, String message)" then resource was not sending)
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Java AI API: bug SIGSEGV or dirrerent API interface?

Post by hoijui »

you write like an indian friend of mine talks :D

did you call this code from the update() function?

... which leads me to assume that you are on windows, correct?
my first guess would be, that this crash happens because the java interface tries to convert some value from C to Java, but the code doing so is incompatible with the actual value (could be a null pointer, for example). best thing would be, to run spring in GDB, and you need debug symbols for that too, of course.
easiest way to do that, is to compile spring yourself on linux.

question to others: is it feasible to do that on windows, these days? (either compile, or get debug symbols for a release, and run with them in GDB on windows)
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: Java AI API: bug SIGSEGV or dirrerent API interface?

Post by PicassoCT »

not ended the war against the redmondions has
just shifted as they are now replaced by different evils
such complexity would never have happened if everybody would have watched more starwars and less game of thrones
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: Java AI API: bug SIGSEGV or dirrerent API interface?

Post by abma »

debug symbols for official builds of windows & linux builds exists, see the _dbg.7z file for example for 96.0 x64 build: http://springrts.com/dl/buildbot/defaul ... ing_dbg.7z
Bla
Posts: 79
Joined: 25 Feb 2013, 14:44

Re: Java AI API: bug SIGSEGV or dirrerent API interface?

Post by Bla »

hoijui wrote: ... which leads me to assume that you are on windows, correct?
I think he's on Linux
playerO1 wrote: [f=0000001] Error: <2> /lib/x86_64-linux-gnu/libpthread.so.0(+0x10340) [0x7fe13f8c0340]
Bla
Posts: 79
Joined: 25 Feb 2013, 14:44

Re: Java AI API: bug SIGSEGV or dirrerent API interface?

Post by Bla »

playerO1 wrote: [f=0000000] Team0 (PeaceBOT) has been decommissioned
[f=0000000] Team1 (NullAI) lived up to their reputation
[f=0000000] Team2 () has been played out
[f=0000000] Team3 () couldn't resist pushing the red button
PlayerO1, the bots shouldn't all die... If you run a blank game with only NullJavaOOAI, does it work? All you get a report saying how much resources it has every few seconds?


If your nulljavaooai does die, then send me your PeaceBOT AI folder please, I wanna see how your AI runs on my side
playerO1
Posts: 57
Joined: 25 Jun 2014, 15:22

Re: Java AI API: bug SIGSEGV or dirrerent API interface?

Post by playerO1 »

Yes, I using Linux.

"Bla", the problem is not in the Bot dead. The problem is the Spring engine crash and BOT can't live in breack virtual vorld and die with Spring in PC memory.

Today I have new crash with new reason. If start 2 equals Java bot in the same team (one team) then spring crash.

Code: Select all

[f=0000000] Connection attempt from playerO1
[f=0000000]  -> Version: 94.1 (ASIM GML OMP)
[f=0000000]  -> Connection established (given id 0)
[f=0000000] Player playerO1 finished loading and is now ingame
[f=0000000] Stall Assist widget disabled for solo players
[f=0000000] GameID: 5851b55371a4a8375828303c1cdf4421
[f=0000000] Error: Segmentation fault (SIGSEGV) in spring 94.1 (ASIM GML OMP)
[f=0000000] Error: Stacktrace:
[f=0000000] Error:   <0> ??:?
[f=0000000] Error:   <1> ??:?
[f=0000000] Error:   <2> /lib/x86_64-linux-gnu/libpthread.so.0(+0x10340) [0x7faeb6460340]
[f=0000000] Error:   <3> ??:?
[f=0000000] Error:   <4> [0x7fae51011790]
[f=0000000] MetalMakers widget disabled for spectators
[f=0000000] Error: Releasing AI Interface Library from file "/home/user/.spring/engines/94.1/AI/Interfaces/Java/0.1/libAIInterface.so". The call to releaseStatic() returned unsuccessfuly.
If I start 2 java bot in differend command then second bot in enemy team have work, but they have problem with call function. First bot do nothing, second bot work (or second nothing and first work). Where I wrote in chat any message, then one of bot not recive this message. Other bot recive 2 (double) message (function message() call twice).
For example my chat with bot:

Code: Select all

[f=0000000] [Threading] Multithreading is enabled and currently running in mode 4
[f=0000001] ResourceMapAnalyzer by Krogothe, initialized for resource 0(Metal)
[f=0000001] <SkirmishAI: PeaceBOT dev (team 2)>: This is a map with no metal spots
[f=0000007] Skirmish AI "I" (ID:0, Short-Name:"PeaceBOT", Version:"dev") took over control of team 1
[f=0000007] Skirmish AI "II" (ID:1, Short-Name:"PeaceBOT", Version:"dev") took over control of team 2
[f=0000008] [Threading] Sim thread CPU affinity not set
[f=0000740] <playerO1> bot get unit com
[f=0000741] <SkirmishAI: PeaceBOT dev (team 2)>: Unit n=1 of 1 seding to team 0 (sharing).
...
[f=0003588] <playerO1> bot status
[f=0003588] <SkirmishAI: PeaceBOT dev (team 2)>: BOT CPU usage: 828 ms (1.19% load)
[f=0003588] <SkirmishAI: PeaceBOT dev (team 2)>: Num of bases 1
Base target: list is empty.
[f=0003588] <SkirmishAI: PeaceBOT dev (team 2)>: BOT CPU usage: 828 ms (1.19% load)
[f=0003588] <SkirmishAI: PeaceBOT dev (team 2)>: Num of bases 1
Base target: list is empty.
As you can see first team recivet double text query. Second team do nothin.
If using 2 different Java bot (NullJavaOOAI and my bot) then all work and good.
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Java AI API: bug SIGSEGV or dirrerent API interface?

Post by gajop »

playerO1 wrote: First bot do nothing, second bot work (or second nothing and first work).
This should be fixed in https://github.com/spring/spring/commit ... 6d97282ff3 . A couple of other issues remain though.
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: Java AI API: bug SIGSEGV or dirrerent API interface?

Post by abma »

playerO1 wrote:[f=0000000] Error: Segmentation fault (SIGSEGV) in spring 94.1 (ASIM GML OMP)
spring 94.1 is very old, don't use it. also spring-multithreaded has a lot of crash bugs, very likely it crashes because of this.
playerO1
Posts: 57
Joined: 25 Jun 2014, 15:22

Re: Java AI API: bug SIGSEGV or dirrerent API interface?

Post by playerO1 »

spring_96.0_minimal-portable-linux32-static.7z and spring_96.0_minimal-portable-linux64-static.7z contains only "C" in folder "/AI/Interfaces/". I take "Java" interface from spring 94.1 and using for testing on 94.1, 96 and 97test. Maybe it is reason of all my problem. Where I can take last Java interface (for Spring 96 and 97)?
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Java AI API: bug SIGSEGV or dirrerent API interface?

Post by hoijui »

as you are on linux, it is pretty easy to compile spring yourself, in which case you will get the Java interface:
http://springrts.com/wiki/Building_Spring_on_Linux
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: Java AI API: bug SIGSEGV or dirrerent API interface?

Post by abma »

playerO1 wrote:I take "Java" interface from spring 94.1 and using for testing on 94.1, 96 and 97test. Maybe it is reason of all my problem
very likely, yes! (and yep, java interface isn't build, something is broken in the buildslave related to java)
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Java AI API: bug SIGSEGV or dirrerent API interface?

Post by Anarchid »

Is proper engine bug.

Infolog: http://hastebin.com/fivilutamu.xml
gdb "set logging on file": http://hastebin.com/itutediruj.pas (no symbols, sorry)
Possible cause: https://github.com/ZeroK-RTS/Zero-K/blo ... ar.lua#L27 -> is an int.

Java interface in question was obtained by compiling spring git @ 138.
playerO1
Posts: 57
Joined: 25 Jun 2014, 15:22

Re: Java AI API: bug SIGSEGV or dirrerent API interface?

Post by playerO1 »

abma wrote:(and yep, java interface isn't build, something is broken in the buildslave related to java)
So I can't compiling interface from last source, isn't it? Or it possible?
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: Java AI API: bug SIGSEGV or dirrerent API interface?

Post by abma »

it compiles, its just something wrong with the java installation on the buildslave.
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Java AI API: bug SIGSEGV or dirrerent API interface?

Post by Anarchid »

it compiles, its just something wrong with the java installation on the buildslave.
player01: that means you can compile it, but the build server is just not very good at it.

Compiling it manually won't make the actual customparams crash go away.
playerO1
Posts: 57
Joined: 25 Jun 2014, 15:22

Re: Java AI API: bug SIGSEGV or dirrerent API interface?

Post by playerO1 »

Today I try compiling String AI interface from source, but I have some trouble. I download Spring 97 sources.
First trouble (fixed): I have linux, and not using OpenJDK, have Oracle JDK. When I start cmake I have message about no JDK found (variable JAVA_HOME not set). For fix it I wrote on console export JAVA_HOME="/usr/java/default" and it work.

Next trouble: I ask about compiling source, and people say to me that I should using "ccmake" for compiling no all spring. I change directory to spring sources and wrote 'ccmake .'.
In settings I change next:

Code: Select all

AI_TYPES                      JAVA 
BUILD_spring-dedicated        OFF                                          
BUILD_spring-headless         OFF                                          
BUILD_spring-legacy           ON                                       
CMAKE_BUILD_TYPE              DEBUG2                                       
CMAKE_INSTALL_PREFIX          /opt                   
next I press 'c' then 'e' then 'g'. program ccmake exit. Next I write 'make' then start compiling process.
But when compiling AI/Wrappers then I have error than JAR librare not exist.
I think the compiling parameter 'vecmath_jar' should be set and this jar file should be exist. I don't know what I heed wrote on this parameter and where I need put this jar file? I see 'vecmath.jar' and 'vecmath-src.jar' on 'engines/94.1/AI/Skirmish/NullOOJavaAI/0.1/jlib'.
Bla
Posts: 79
Joined: 25 Feb 2013, 14:44

Re: Java AI API: bug SIGSEGV or dirrerent API interface?

Post by Bla »

playerO1 wrote:Today I try compiling String AI interface from source, but I have some trouble. I download Spring 97 sources.
First trouble (fixed): I have linux, and not using OpenJDK, have Oracle JDK. When I start cmake I have message about no JDK found (variable JAVA_HOME not set). For fix it I wrote on console export JAVA_HOME="/usr/java/default" and it work.

Next trouble: I ask about compiling source, and people say to me that I should using "ccmake" for compiling no all spring. I change directory to spring sources and wrote 'ccmake .'.
In settings I change next:

Code: Select all

AI_TYPES                      JAVA 
BUILD_spring-dedicated        OFF                                          
BUILD_spring-headless         OFF                                          
BUILD_spring-legacy           ON                                       
CMAKE_BUILD_TYPE              DEBUG2                                       
CMAKE_INSTALL_PREFIX          /opt                   
next I press 'c' then 'e' then 'g'. program ccmake exit. Next I write 'make' then start compiling process.
But when compiling AI/Wrappers then I have error than JAR librare not exist.
I think the compiling parameter 'vecmath_jar' should be set and this jar file should be exist. I don't know what I heed wrote on this parameter and where I need put this jar file? I see 'vecmath.jar' and 'vecmath-src.jar' on 'engines/94.1/AI/Skirmish/NullOOJavaAI/0.1/jlib'.
If you're compiling java files, can't you use an IDE like eclipse?
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Java AI API: bug SIGSEGV or dirrerent API interface?

Post by Anarchid »

1) cmake, not ccmake. Dunno, vecmath.jar should be automatically built and referenced for you >.>
2) No, you cant compile the interface in Eclipse, because it's a JNI thing on top of an awk-generated bunch of c++ files.
Post Reply

Return to “AI”