You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a strange behaviour for the Call when triggered in go routines, a data race will be detected from timer triggered go routine but not in channel triggered go routine, see the bellow test cases:
The text was updated successfully, but these errors were encountered:
zdevwu
changed the title
invocation from timer triggered go routing will report data race
invocation from timer triggered go routine will report data race
Apr 18, 2024
Hey @zdevwu, are you expecting the mock generated methods to be concurrency safe? If so, they're not expected to be.
With respect to the two cases you gave above, the first case does not race as he first goroutine only gets unblocked after the mock expectation is declared which serializes the the Sum expectation setting and the mock call to Sum.
Thanks for getting back @r-hang, can you elaborate a bit on the second case please? Although not explicitly sending the signal by closing the releaseChannel to continue to launch the go routine, the timer in second case makes sure the mock happens before the nested go routine that is calling Sum start running, both cases the mock happens before the call, but race is only detected in the second case with timer released go routine.
There is a strange behaviour for the
Call
when triggered in go routines, adata race
will be detected from timer triggered go routine but not in channel triggered go routine, see the bellow test cases:The fork to demo the issue here:
Triage Notes for the Maintainers
The text was updated successfully, but these errors were encountered: