Skip to content

RegisterTLSConfig can panic with "fatal error: concurrent map writes" #610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
daniel-nichter opened this issue Jun 7, 2017 · 0 comments
Closed

Comments

@daniel-nichter
Copy link
Contributor

If multiple goroutines call RegisterTLSConfig Go can panic because the internal map is not guarded: tlsConfigRegister[key] = config

Affects all versions of driver including latest SHA as of today.

Suggested fixes:

  1. Guard the map, or
  2. Document that this func isn't thread-safe and caller should only call it once

Best is probably option 1 and then document that callers shouldn't (and don't need to) re-register the same TLS config more than once (unless, of course, certs change).

julienschmidt added a commit that referenced this issue Jun 9, 2017
julienschmidt added a commit that referenced this issue Jun 16, 2017
* utils: guard tlsConfigRegister by a lock

Fixes #610

* utils: move TLSConfig lock and clone logic to helper func
tolsen pushed a commit to tolsen/mysql that referenced this issue May 17, 2018
* utils: guard tlsConfigRegister by a lock

Fixes go-sql-driver#610

* utils: move TLSConfig lock and clone logic to helper func
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

No branches or pull requests

1 participant