Menu

#4261 Princess NPE bug.

stable 0.40
closed
princess (38)
fixed
1
2014-12-25
2014-09-28
Anonymous
No

My be the same as bug [#4259]

Princess throwing a NPE exception:

Exception in thread "Princess-precognition (Draconis Combine)" java.lang.NullPointerException
at megamek.common.Game.getEntities(Game.java:1510)
at megamek.common.Game.getEntities(Game.java:1493)
at megamek.common.Compute.isEnemyIn(Compute.java:368)
at megamek.common.MoveStep.isMovementPossible(MoveStep.java:2910)
at megamek.common.pathfinder.MovePathFinder$MovePathLegalityFilter.shouldStay(MovePathFind​er.java:181)
at megamek.common.pathfinder.MovePathFinder$MovePathLegalityFilter.shouldStay(MovePathFind​er.java:149)
at megamek.common.pathfinder.AbstractPathFinder$Filter.doFilter(AbstractPathFinder.java:11​3)
at megamek.common.pathfinder.AbstractPathFinder.run(AbstractPathFinder.java:296)
at megamek.common.pathfinder.AbstractPathFinder.run(AbstractPathFinder.java:325)
at megamek.client.bot.princess.PathEnumerator.recalculateMovesFor(PathEnumerator.java:219)​
at megamek.client.bot.princess.Precognition.run(Precognition.java:196)

Thanks,

Dav

Related

Bugs: #4259
Bugs: #4282
Bugs: #4353

Discussion

  • Nicholas Walczak

    • assigned_to: Nicholas Walczak
    • Resolution: none --> accepted
    • Milestone: undetermined --> stable 0.40
     
  • Nicholas Walczak

    This actually isn't just a princess issue. This is an issue with the entity position cache in Game. It looks like for some reason there' are stale entity Ids in the cache.

     
    • Nicholas Walczak

      I'm actually going to go back on my previous statement. I now wonder if this might be related to concurrency issues. I could especially see this being the case in a game with simultaneous firing on (which is not compatible with Princess, partially because of concurrency issues).

      I cannot find any way that Game.entityPosLookup would be out of sync with Game.entityIds. The only way I could see this happening if something like Game.reindexEntities() is being called concurrently with Game.getEntities(2). This could potentially happen if Precognition is running while the game phase changes or possibly when a turn ends (whenever the Server sends a new Entities vector to the Client).

      I guess one option would be to make Game thread safe...

       
  • Deric Page

    Deric Page - 2014-10-02

    Your hypothesis is sound as Precognition spins off it's own threads so Princess can be "thinking" while other things are going on.

    Making Game thread-safe is the best long-term fix. I know it's a big undertaking (because I've started on some of it) and there's a good chance of a performance hit, but not only can it fix this issue, it should help prevent future issues.

     
    • Nicholas Walczak

      Yea, when I was looking into Princess threading issues with simltaneous phases, I had considered making Game thread safe, but it seemed like a lot of work, and I wasn't sure it was necessary.

      I agree that it's probably something we should do, but I didn't want to expend the effort on it at the time. If you're already working on it, I can reassign the ticket to you (or you can reassign the ticket to you).

       
  • Deric Page

    Deric Page - 2014-10-02

    Yeah, I'll go ahead and take it. I'll go at a bit at a time, starting with the entity position cache.

     
  • Deric Page

    Deric Page - 2014-10-02
    • assigned_to: Nicholas Walczak --> Deric Page
     
  • Deric Page

    Deric Page - 2014-11-02

    I just submitted [r11333] to make the entity position cache thread safe. I'm not closing this ticket at this time as we haven't positively identified that as the cause of the issue (though it's a fair bet).

     

    Related

    Commit: [r11333]

  • Deric Page

    Deric Page - 2014-12-24

    As this NPE hasn't happened in my testing and hasn't been re-reported since [r11333], I'm marking this closed. If it happens again, please open a new ticket and attach the full log and save files.

     

    Related

    Commit: [r11333]

  • Deric Page

    Deric Page - 2014-12-24
    • labels: --> princess
    • Resolution: accepted --> fixed
     
  • Dylan Myers

    Dylan Myers - 2014-12-25
    • Status: open --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB