microsoftgraph / microsoftgraph/msgraph-sdk-go-core

Erroneous Go race detection

Open
#359 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

status:waiting-for-triage type:bug
Dominant language
Go
Stars
22
Forks
16
Avg merge
7h 53m
Merged PRs (30d)
1

Description

Describe the bug

Currently, running parallel tests using this package with race detection on causes false positives of data races:

WARNING: DATA RACE
Read at 0x000005260ee8 by goroutine 11:
github.com/microsoftgraph/msgraph-sdk-go-core.getInstance()
/home/runner/go/pkg/mod/github.com/microsoftgraph/msgraph-sdk-go-core@v1.3.2/error_mappings_registry.go:19 +0x30
github.com/microsoftgraph/msgraph-sdk-go-core.GetErrorFactoryFromRegistry()
/home/runner/go/pkg/mod/github.com/microsoftgraph/msgraph-sdk-go-core@v1.3.2/error_mappings_registry.go:55 +0x2b

...

Previous write at 0x000005260ee8 by goroutine 34:
github.com/microsoftgraph/msgraph-sdk-go-core.getInstance()
/home/runner/go/pkg/mod/github.com/microsoftgraph/msgraph-sdk-go-core@v1.3.2/error_mappings_registry.go:23 +0x12f
github.com/microsoftgraph/msgraph-sdk-go-core.GetErrorFactoryFromRegistry()
/home/runner/go/pkg/mod/github.com/microsoftgraph/msgraph-sdk-go-core@v1.3.2/error_mappings_registry.go:55 +0x2b

The issue seems to be in:
https://github.com/microsoftgraph/msgraph-sdk-go-core/blob/a8bcb6c81e33e77c3d5338337e5da8b8085cd932/error_mappings_registry.go#L19
The optimistic nil check triggers a read-write race detection - perhaps it can be disabled when go test -race is on?

Expected behavior

Go's race detection won't fail tests when using the package in it

How to reproduce

Run tests using the package in parallel with -race specified in go test's arguments.

SDK Version

No response

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output
Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with error_mappings_registry.go around lines 19 and 55, then reproduce the issue by running parallel tests with go test -race. Trace the reported read and write and verify that the package's race-enabled tests complete without false-positive race failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.