Skip to main content
Backend, Engineering

Data Race Patterns in Go

2June,2022 / Global
Featured image for Data Race Patterns in Go
Image
Figure 1A: Data race due to loop index variable capture.
Image
Figure 1B: Data race due to idiomatic “err” variable capture.
Image
Figure 1C: Data race due to named return variable capture.
Image
Figure 2: Data race in slices even after using locks.
Image
Figure 3: Data race due to concurrent map access.
Image
Figure 4A: Data race due to method invocation by-reference or by-pointer.
Image
Figure 4B: sync.Mutex Lock/Unlock signature.
Image
Figure 5: Data race when mixing message passing with shared memory.
Image
Figure 6A: Data race due to incorrect WaitGroup.Add() placement.
Image
Figure 6B: Data race due to defer statement ordering leading to incorrect WaitGroup.Done() placement.
Image
Figure 7: Summary of data races.
Milind Chabbi

Milind Chabbi

Milind Chabbi is a Staff Researcher in the Programming Systems Research team at Uber. He leads research initiatives across Uber in the areas of compiler optimizations, high-performance parallel computing, synchronization techniques, and performance analysis tools to make large, complex computing systems reliable and efficient.

Murali Krishna Ramanathan

Murali Krishna Ramanathan

Murali Krishna Ramanathan is a Senior Staff Software Engineer and leads multiple code quality initiatives across Uber engineering. He is the architect of Piranha, a refactoring tool to automatically delete code due to stale feature flags. His interests are building tooling to address software development challenges with feature flagging, automated code refactoring and developer workflows, and automated test generation for improving software quality.

Posted by Milind Chabbi, Murali Krishna Ramanathan