Skip to content

[Bug] Data races between initDecoder and initEncoder operations #529

@sunadoi

Description

@sunadoi

In v0.10.4, A data race condition has been detected when running tests with -race flag.

スクリーンショット 2024-12-17 22 31 41

I suspect the following is occurring from this PR (#490 ):

  • runtime.AnalyzeTypeAddr() is being called in both initDecoder and initEncoder.
  • Although using sync.Once, since initEncoderOnce and initDecoderOnce are separate variables, concurrent calls to initEncoder and initDecoder result in race conditions in runtime.AnalyzeTypeAddr() operations.

In our project, tests that simultaneously use json.Marshal and json.Unmarshal have become flaky.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions