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

Concurrent map read/write on getCurrentTestPhaseObject func #48

Open
samybenatt opened this issue Nov 24, 2022 · 0 comments
Open

Concurrent map read/write on getCurrentTestPhaseObject func #48

samybenatt opened this issue Nov 24, 2022 · 0 comments

Comments

@samybenatt
Copy link

When using t.parallel()within a test function from a suite containing multiple tests, the allure.Test() can be called concurrently.
However, when this is the case, getCurrentTestPhaseObject function can be called concurrently by multiple tests running in parallel (it's not systematic, but happens quite often).
When it happens, the following fatal error is occuring:

fatal error: concurrent map read and map write

goroutine 401 [running]:
runtime.throw(0x1877cc7, 0x21)
	/usr/local/[email protected]/1.16.15/libexec/src/runtime/panic.go:1117 +0x72 fp=0xc000a33bb0 sp=0xc000a33b80 pc=0x1039d92
runtime.mapaccess2_faststr(0x178b9e0, 0xc0002d83c0, 0xc0005353b0, 0x4c, 0xc000882a80, 0xc0002d8780)
	/usr/local/[email protected]/1.16.15/libexec/src/runtime/map_faststr.go:116 +0x4a5 fp=0xc000a33c20 sp=0xc000a33bb0 pc=0x1016445
github.com/dailymotion/allure-go.getCurrentTestPhaseObject(...)
	/Users/*/go_repos/pkg/mod/github.com/dailymotion/[email protected]/test_phase_container.go:112
github.com/dailymotion/allure-go.Test.func2(0xc000c72120, 0xc000882a80)
	/Users/*/go_repos/pkg/mod/github.com/dailymotion/[email protected]/test.go:98 +0xa8 fp=0xc000a33e20 sp=0xc000a33c20 pc=0x16ba868
github.com/dailymotion/allure-go.Test(0xc000882a80, 0xc0001e2f50, 0x4, 0x4)

To prevent that, I would say that there are two solutions applicable:

  1. Introduce a sync.Mutex in the function getCurrentTestPhaseObject from test_phase_container.go
  2. Change the type of testPhaseObjects from init.go to sync.Map and adapt getCurrentTestPhaseObject accordingly

Let me know if more details are required or if there are inconsistencies in what I describe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant