My bot have lag on internet game. - Page 2

My bot have lag on internet game.

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

Moderators: hoijui, Moderators

What reason for this bug?

Poll ended at 20 Sep 2014, 14:28

Mistmatch AI interface version
1
20%
Bad BOT logic
1
20%
Spring engine have bug
3
60%
It is a Java bug
0
No votes
 
Total votes: 5

abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: My bot have lag on internet game.

Post by abma »

i can reproduce the crash "Failed to allocate memory" now, not sure why it happens atm.
playerO1
Posts: 57
Joined: 25 Jun 2014, 15:22

Re: My bot have lag on internet game.

Post by playerO1 »

It may be same "out of bounds" bug in C interface.
What I mean, example: array A from 10 element(0..9), you may write on 10 element A[10]=123; But A[10] may adress on other wariable.

Maybe bug in the next line: https://github.com/abma/spring/blob/dev ... ge.c#L1153 ? I'm not know nice C++/C, but not undestand, what will be doing programm, if it will be using this last element "size_t firstFree = skirmishAiImpl_size;", if bounds on cicle "sai < skirmishAiImpl_size;". Hm... Or whay need do "firstFree = skirmishAiImpl_size;" if this wariable always will be rewrite?
p.s.: AI Interface from Spring 94.0 not have this bug.
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: My bot have lag on internet game.

Post by abma »

i've created a bug report about this: http://springrts.com/mantis/view.php?id=4565

but i'm not sure if i / someone else will fix it soon.

when checking code you should use the official source code repository which is here:

https://github.com/spring/spring/blob/d ... ge.c#L1154

this file seems to be different in comparison to the fork of abma.

java ai interface code recently had changed, not sure if related.

i guess this code does reuse existing slots for ais, i don't see a bug there as index is checked for bounds.
playerO1
Posts: 57
Joined: 25 Jun 2014, 15:22

Re: My bot have lag on internet game.

Post by playerO1 »

Abma, I today check again cycle (for) on Java, then check on C++. And now I realy see bug on index using.
Example, what you think of result of next code:

Code: Select all

int i;
for (i=0; i<10; i++);
printf("i=%i",i)
You think on terminal you will be see "i=9" or "i=10"?

I see on code at line 1153 variable "sai" using for cycle. After cycle (I see change - no break on spring/spring repository) this variable always will be equals "skirmishAiImpl_size". Then at line 1163 do check on null "if (skirmishAiImpl_className[sai] == NULL)" - it equals as you will be check next index "skirmishAiImpl_className[skirmishAiImpl_size]". I don't read about size "skirmishAiImpl_className", but if array size was limited as skirmishAiImpl_size - then you realy can have problem with out of bounds, and can check other wariables.
The second danger line is 1163, 1191, 1212.
.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: My bot have lag on internet game.

Post by hoijui »

... indeed... good find!
what the heck have i been thinking there? :D
and how can that ever work?
.. much have been someone else coding it! ( dum di dum... :/ )

yeah, both these loops (JavaBridge.c line 1153 and line 1203) seem wrong. they are different, even though they should be doing the same, and neither is correct. should be corrected and moved to a function, i would say.
luckily, i commented the code so one know what the code should be doing. :D
.. me so smart!

.. should i do the commit, or will someone of you do it?
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: My bot have lag on internet game.

Post by abma »

hoijui wrote:.. should i do the commit, or will someone of you do it?
if you have still a build env up, it would be great when you do the commit :-)

else i need some hint what needs to be changed. i still don't fully understand what this code should do.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: My bot have lag on internet game.

Post by hoijui »

made 2 small fix commits.
thanks playerO1 and abma!

the commits were not tested, but they are small enough to.. let me think they should work. ;-)
they will be in the develop branch soon, i guess.
playerO1
Posts: 57
Joined: 25 Jun 2014, 15:22

Re: My bot have lag on internet game.

Post by playerO1 »

I compile last Engine with AI interface version (17 october from github sources), then paste AI interface into Spring 98 folder (I not see AI interface in Spring 98 Linux 64). And I see 2 bug:
1. Two or more my bot can not work together: one of him have full control, secong do nothink. (Old bug, on Spring 97 it will be fixed, but now...) (See http://springrts.com/mantis/view.php?id=2840 and http://springrts.com/phpbb/viewtopic.ph ... 65#p560565)
2. Spring 98 + Zero-K mod + NullOOJavaAI take crash :(
playerO1
Posts: 57
Joined: 25 Jun 2014, 15:22

Re: My bot have lag on internet game.

Post by playerO1 »

I watch that Java AI Interface file on github have 2-3 years old of modify. Only one file have been modifed - it is "JavaBridge.c". Becouse I see, that Java interface from Spring 94.1 work on Spring 96+ZK mod, I copy from github file "JavaBridge.c" from ~Spring 95 version into sources from Spring 98 develop from GitHub.
I modify only one line in old file for compile new AI interface, becouse it was no compiling without it (modify method "void java_establishSpringEnv()").
I test this modifed interface: with TA/BA mod it can work, with ZK it crash again. I think bug can exist on other files, not on "JavaBridge.c". The bug can contain on other Spring files and modules.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: My bot have lag on internet game.

Post by hoijui »

you have a patch for JavaBridge.c?
if so, please make a pull request on github, and it will be checked out. also include a description of what exactly this is supposed to fix.
playerO1
Posts: 57
Joined: 25 Jun 2014, 15:22

Re: My bot have lag on internet game.

Post by playerO1 »

hoijui wrote:you have a patch for JavaBridge.c?
No, I mean that this file can not contain bug.
I try find bug on "JavaBridge.c", but I not found bug on this file. And I am sure that this file not have bug for make this crash.
So, if this file not have bug, and only this file have modifen on last year, it mean that bug can contain only on other Spring modules: on Spring engine, or "ExternalAI/Interface/*.h", "CUtils/*" or "AI/Interfaces/C/src/*" or other.
mojjj
Posts: 1
Joined: 27 Sep 2016, 09:31

Re: My bot have lag on internet game.

Post by mojjj »

Post Reply

Return to “AI”