Skip to content

Fix clone functions of InputStats and OutputStats to prevent data race condition#400

Merged
frairon merged 1 commit intolovoo:masterfrom
leepro:fix-clone-function
Dec 9, 2022
Merged

Fix clone functions of InputStats and OutputStats to prevent data race condition#400
frairon merged 1 commit intolovoo:masterfrom
leepro:fix-clone-function

Conversation

@leepro
Copy link
Contributor

@leepro leepro commented Nov 26, 2022

&(*x) doesn't clone the data (that pattern has used for the clone() function for goka.InputStats and goka.OutputStats) into a new instance because it is simplified to x. (This can be detected by staticcheck SA4001) So, it has made data race condition when a cloned stats is used. We have observed this in Goka web monitor and other places where it is using View.Stats.

This can be reproduced with a goka web monitor enabled application by turning on the Go race detector -race.

Screen Shot 2022-11-26 at 12 51 42 AM

Screen Shot 2022-11-26 at 12 50 59 AM

@frairon
Copy link
Contributor

frairon commented Nov 28, 2022

good catch, many thanks for the fix!

@leepro
Copy link
Contributor Author

leepro commented Nov 28, 2022

Thanks! Can you please allow this PR to be merged into master?

@leepro leepro closed this Nov 29, 2022
@leepro leepro deleted the fix-clone-function branch November 29, 2022 00:30
@leepro leepro restored the fix-clone-function branch November 29, 2022 00:30
@leepro leepro reopened this Nov 29, 2022
@frairon frairon merged commit 6b160fc into lovoo:master Dec 9, 2022
@frairon
Copy link
Contributor

frairon commented Dec 9, 2022

really sorry for the delay, things got out of sight over here.

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.

3 participants