Skip to content

Fix race condition in loadSession with shared session cache#386

Open
thesinakamali wants to merge 1 commit intorefraction-networking:masterfrom
thesinakamali:fix/session-cache-race-condition
Open

Fix race condition in loadSession with shared session cache#386
thesinakamali wants to merge 1 commit intorefraction-networking:masterfrom
thesinakamali:fix/session-cache-race-condition

Conversation

@thesinakamali
Copy link
Copy Markdown

When multiple goroutines share a ClientSessionCache, loadSession() returns a *SessionState pointer that is shared across connections. Subsequent code (e.g. SessionTicketExtension.InitializeByUtls) mutates this session object, causing a data race. Fix by making a shallow copy of the SessionState immediately after retrieving it from the cache.

When multiple goroutines share a ClientSessionCache, loadSession()
returns a *SessionState pointer that is shared across connections.
Subsequent code (e.g. SessionTicketExtension.InitializeByUtls) mutates
this session object, causing a data race. Fix by making a shallow copy
of the SessionState immediately after retrieving it from the cache.
@maciejkmak
Copy link
Copy Markdown

@thesinakamali man your PR pointed me into good direction when investigating why my server is failing in production. I spent over 60h in total looking for problem.

THANK YOU! Live long and prosper 🖖

to maintainers: please merge it

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.

2 participants