Skip to content

Conversation

@ImmortalxAnimes
Copy link

The bot was crashing with fatal error: concurrent map writes during group call events. This happened because the inputGroupCalls map was being accessed from multiple goroutines at the same time. It was being written inside UpdateGroupCall while other parts of the code like OnRequestBroadcastTimestamp, OnRequestBroadcastPart, and OnUpgrade were reading from it. That race condition caused the random panics.

What I changed

  • Added an inputGroupCallsMutex (sync.RWMutex) to the Context struct.
  • Wrapped every access to inputGroupCalls with proper locking:
    • Writes (Lock/Unlock): UpdateGroupCall, getInputGroupCall
    • Reads (RLock/RUnlock): all callbacks, convertGroupCallId, Stop, joinPresentation

Fixes #36

Example

// Before: unsafe access
ctx.inputGroupCalls[chatID] = &tg.InputGroupCallObj{...}

// After: protected with mutex
ctx.inputGroupCallsMutex.Lock()
ctx.inputGroupCalls[chatID] = &tg.InputGroupCallObj{...}
ctx.inputGroupCallsMutex.Unlock()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fatal error: concurrent map writes in handleUpdates

1 participant