StevensSEC / pokemonbattlelib

A portable library for accurately simulating Pokemon battles.
GNU General Public License v3.0
12 stars 2 forks source link

fatal error: concurrent map writes #369

Closed dyc3 closed 3 years ago

dyc3 commented 3 years ago

Current Behavior

While stress testing my ssw project, I encountered this race condition. It occurs in the code below:

func (hb *httpBattle) QueueNextTurn(targetId int, turn Turn) {
    hb.queuedTurns[targetId] = turn
}

Should be easily fixed with a lock.

To Reproduce Queue multiple turns for the same battle at the same time.

Expected Behavior

Should not crash.

Evironment:

Additional context Add any other context about the problem here.