[Pogamut-list] Bot state change to dead freezes code execution.

Piotr.Murach pogamut-forum at diana.ms.mff.cuni.cz
Wed Jul 21 18:37:03 CEST 2010


Re: Bot state change to dead freezes code execution.

Author: Piotr.Murach

I am sorry for late reply but been busy testing code ...

In answer to your question Jakub, I am running my custom built bot and the native bot connected 
by issuing the addbot command.The last time this happened bot bots had frozen in the middle of the
1on1Joust map. 

Since that time I have run quite few batches of experiments and didn not get this error again. However, 
you may be right in saying that there is probably some racing condition in which case replicating it 
is very difficulat and can take some time to occur again. I only call the code to stop the bot once 
per execution of the bot. To be precise it is called after fixed number of actions is executed. There is
no other place that issues stoping or killing commands.

A single experimental run consists of starting the ucc server, starting the bot controller and connecting the two
bots and then shutting down the whole thing in exact way as was presented by Jacob Schrum. The only place my code 
differs is when I am executing my own bot as I am using the UT2004BotRunner to achieve this, plus the launching 
of the native bot as mentioned earlier. Now during each run I am executing a fixed sequence of actions and regardles
whether my bot dies or not I am stoping it and restarting the server. This needs to be repeated 2000 times.
During the last trials I am getting exactly the same error but different from the dead bot state. It happens
at different times, once I got it after 12 runs, then after 47. What is common, is that it always happens after the 
server has been initialised and during my bot launching. Here is the error I am getting:

Exception in thread "main" ComponentCantStartException[UT2004Bot[ThiefBot]: Can't start: BusAwareCountDownLatch: Interrupted because bus was stopped (fatal error, or watched component stopped) while waiting on the latch. (caused by: BusAwareCountDownLatch: Interrupted because bus was stopped (fatal error, or watched component stopped) while waiting on the latch.)]
        at cz.cuni.amis.pogamut.base.agent.impl.AbstractAgent.start(AbstractAgent.java:408)
        at cz.cuni.amis.pogamut.base.agent.utils.runner.impl.RemoteAgentRunner.startAgent(RemoteAgentRunner.java:70)
        at servers.tbcs.ThiefBotControlServer.runServerOnceForParameters(ThiefBotControlServer.java:213)
        at servers.tbcs.ThiefBotServerTask.main(ThiefBotServerTask.java:61)
Caused by: BusStoppedInterruptedException[BusAwareCountDownLatch: Interrupted because bus was stopped (fatal error, or watched component stopped) while waiting on the latch.]
        at cz.cuni.amis.pogamut.base.component.bus.event.BusAwareCountDownLatch.checkBusStop(BusAwareCountDownLatch.java:173)
        at cz.cuni.amis.pogamut.base.component.bus.event.BusAwareCountDownLatch.await(BusAwareCountDownLatch.java:167)
        at cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot.startAgent(UT2004Bot.java:174)
        at cz.cuni.amis.pogamut.base.agent.impl.AbstractAgent.start(AbstractAgent.java:394)



And the exact place where this happens in my code is:

            UT2004BotFactory factory =
                   new UT2004BotFactory(new UT2004BotModule(ThiefBot.class));
          
            UT2004BotRunner botRunner =
                   new UT2004BotRunner(factory, Constants.BOT_NAME) {


                @Override
                protected void preStartHook(UT2004Bot agent) throws PogamutException {
                    super.preStartHook(agent);
                    ((ThiefBot) agent.getController()).setBotParameters(params);
                }

            };
            // Connect native bot to the ucc server.
            server.getAct().act(nativeAgent);
            IAgent agent = botRunner.startAgent();      //   THIS IS THE LINE THAT ERRORS (SOMETIMES)!!!!
            

            // Wait until the bot finishes and close Pogamut platform.
            new WaitForAgentStateChange(agent.getState(), IAgentStateStopped.class).await();
            agent.kill();
            Pogamut.getPlatform().close();

It appears to be a problem with CountDownLatch which seems to control the starting of bots and possibly this is where 
this racing condition may be occuring and later causing either freeze of the app during execution of the bot or before
it even starts. Please understand that I am in no way trying to patronise anyone but my priority is to get this fixed
so I can set these experiment running and start getting some results.  

As always if you have any ideas how I can even temporarily overcome these send them my way. Once again I am really 
grateful for all the hard work you doing!

Thanks,

P.

-- 
Reply Link: <http://diana.ms.mff.cuni.cz/main/tiki-view_forum_thread.php?forumId=4&comments_reply_threadId=4&comments_parentId=293&post_reply=1#form>





More information about the Pogamut-list mailing list