View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
---|---|---|---|---|---|---|---|---|---|
0002162 | AI | AI | public | 2010-10-06 18:18 | 2014-06-26 18:57 | ||||
Reporter | gajop | ||||||||
Assigned To | gajop | ||||||||
Priority | normal | Severity | minor | Reproducibility | always | ||||
Status | resolved | Resolution | fixed | ||||||
Summary | 0002162: Undefined behavior when multiple java bots share the same package.class as entry point | ||||||||
Description | When at least two java bots in the same game have the same main class entry point, f.e nulloojavaai.NullOOJavaAIFactory, either one of them (probably last one added, but didn't verify that) will "overwrite" the other one, i.e it will load instead of the other one. Not looking at the source code, my guess is that both classpaths are loaded, and thus later classpaths might override the old ones if they share the same package.class. The end results is that isntead of playing a match of MyAI (a java AI) vs NullOOJavaAI, I sometimes end up playing MyAI vs MyAI and sometimes NullOOJavaAI vs NullOOJavaAI. I obviously fixed it by editing the package name and AIInfo.lua, but this is a bug, isn't it? I would probably need to provide different packages or at least version numbers (haven't tried if it works) if i wanted two AIs with the same named package.class to play in the same game. | ||||||||
Tags | No tags attached. | ||||||||
Attached Files |
|
Relationships | |||||||
|
Notes | |
hoijui (reporter) 2010-10-07 00:52 |
spring master (0.82.3-751-g1fdbce6): AI/Interfaces/Java/src/main/native/JavaBridge.c:1090 AI/Interfaces/Java/src/main/native/JniUtil.c:254 i am using a separate class-loader for each AI implementation, and a, getting the class though that ones findClass() method: http://download.oracle.com/javase/6/docs/api/java/lang/ClassLoader.html#findClass(java.lang.String) http://download.oracle.com/javase/6/docs/api/java/net/URLClassLoader.html#findClass(java.lang.String) ... which according to the docs should not check the parent class loader before trying to load its-self (that is done by loadClass()) soo.. i don't know how this happens. any idea? |
Petah (reporter) 2012-01-16 08:13 |
The class specified in the AIInfo.lua (key: className) is only constructed once no matter how many AIs are added to the game. E.g. if I make a game with 2 of the same AIs, the engine creates one instance of the class and calls each event twice on the same class. NullJavaAI and NullJavaOOAI also have this behavior. If you add 2 of the same to a game, they both think that they are the same player/team (see the team ID when they message there resource stats every 10 secs), because the team ID is overridden in the init event when its called a second time. Is this a bug, or am I just missing something? http://springrts.com/phpbb/viewtopic.php?f=15&t=27471&sid=7c536673d255bda041bb22a63d6b45c9 |
meriton (reporter) 2014-05-18 23:31 |
I see this as well. Testcase: public class MerAI extends AbstractOOAI { @Override public int init(int skirmishAIId, OOAICallback callback) { try { Logger.init(callback); Logger.log("Init for " + this); } catch (Throwable t) { return -1; } return 0; } } Logfile for team 0: Init for merai.MerAI@1476842 Logfile for team 1: Init for merai.MerAI@1476842 As we can see from the identical hash codes, the *very same instance* of AbstractOOAI is invoked with different callbacks. Since AbstractOOAI assumes the callback remains the same, there is nothing an AIs can do to work around this. |
Issue History | |||
Date Modified | Username | Field | Change |
---|---|---|---|
2010-10-06 18:18 | gajop | New Issue | |
2010-10-07 00:52 | hoijui | Note Added: 0005702 | |
2012-01-16 08:13 | Petah | Note Added: 0008166 | |
2014-05-18 23:31 | meriton | Note Added: 0013112 | |
2014-06-26 18:13 | gajop | Changeset attached | => spring develop ebf20096 |
2014-06-26 18:13 | gajop | Assigned To | => gajop |
2014-06-26 18:13 | gajop | Status | new => resolved |
2014-06-26 18:13 | gajop | Resolution | open => fixed |
2014-06-26 18:57 | Kloot | Relationship added | duplicate of 0002840 |