Closed steve-offutt closed 4 years ago
@qjerome Adding a RWMutex to the [4]Element
global used for debugging fixes the race condition observed when building with -race
. This fix is useful for people who use this package in a CI/CD pipeline that require the -race
flag be set in their build to detect race conditions. I know that this variable is only used for debugging. However, this race breaks CI/CD.
I thought about this solution however it breaks the whole purpose of parallelization. Having a shared resource with a mutex across thread will cause threads to wait for that resource and will decrease performances. I will try to come up with another fix.
go build -race tools/evtxdump/... && ./evtxdump -s $EVTX_FILE
produces a race warning. It was observed that the data race could reside here: https://github.com/0xrawsec/golang-evtx/blob/fb1efdb926d27bb62f9b82f532fdd6a66fa14741/evtx/utils.go#L80-L83 This is most likely due to the fact that multiple goroutines are attempting to alter the global arraylastParsedElements
. After commenting out the function body ofUpdateLastElements
and rerunning the same commands mentioned above, there is no longer a race condition warning.I'm not aware of the purpose of
lastParsedElements
. However, the comment for the variable mentions that it is for debug purposes so I assume that the impact of commenting out the code inUpdateLastElements
to be small.