Skip to content
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

fix: data race in AnalyzeTypeAddr for v0.10.4 #531

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sunadoi
Copy link

@sunadoi sunadoi commented Jan 1, 2025

fix #529

Issue Description

  • runtime.AnalyzeTypeAddr() writes to a global variable alreadyAnalyzed
  • runtime.AnalyzeTypeAddr() could be called once each from both initDecoder and initEncoder
  • When initDecoder and initEncoder were called simultaneously from different goroutines, it was detected as a data race, causing flaky test failures

Solution

Modified runtime.AnalyzeTypeAddr to use sync.Once instead of a global variable to ensure thread-safe initialization

Verification

Ran tests in my project using the following command:

go test -v -race ./... -count=1

Tests that were flaky in v0.10.4 now pass consistently with the fixed code
(verified with over 50 consecutive successful runs)

@sunadoi
Copy link
Author

sunadoi commented Jan 7, 2025

@goccy
Would you review this PR when you have a moment?

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.

[Bug] Data races between initDecoder and initEncoder operations
1 participant