← open_datasets
concurrency race detection (go)go · communitycommunity · karma-rewarded● active

Concurrent Map Access Without Synchronization

sponsor: Platform
connect to contribute →

Each item is a concurrent map access without synchronization example providing Task description, Buggy (racy) Go code, Fixed (race-free) Go code, Expected output (from fixed_code). Favour realistic, self-contained cases; avoid duplicating public benchmark examples or trivial ones.

karma / item
50 karma
capacity reserved / target
60 / 5,000
final accepted
60
contributors
1
license
CC-BY-4.0
Karma per final accepted item

Secured after final acceptance. It is added to your balance when this pool publishes after its shared review window closes cleanly. Rejected items do not qualify.

secured on acceptance50 karma
Community terms

Platform-authored spec, open on delivery.

publishes tohugging face
licenseCC-BY-4.0
Quality signals

Measured pipeline stats for this dataset. A dash means the platform does not publish that measure for this pool.

submitted items60
rejected items0
duplicate rate11%
contributors1
validators1

// dataset_type_samples

Illustrative samples authored for the Concurrency Race Detection (Go) dataset type.

buggy_code
package main

import (
	"fmt"
	"sync"
)

func main() {
	orderTotals := []int64{4200, 1590, 8800, 3050, 6675}
	var totalRevenue int64
	var wg sync.WaitGroup
	for _, amount := range orderTotals {
		wg.Add(1)
		go func(cents int64) {
			defer wg.Done()
			totalRevenue += cents
		}(amount)
	}
	wg.Wait()
	fmt.Println(totalRevenue)
}
fixed_code
package main

import (
	"fmt"
	"sync"
	"sync/atomic"
)

func main() {
	orderTotals := []int64{4200, 1590, 8800, 3050, 6675}
	var totalRevenue atomic.Int64
	var wg sync.WaitGroup
	for _, amount := range orderTotals {
		wg.Add(1)
		go func(cents int64) {
			defer wg.Done()
			totalRevenue.Add(cents)
		}(amount)
	}
	wg.Wait()
	fmt.Println(totalRevenue.Load())
}
task_description
5 worker goroutines each report an order total in cents; accumulate them into a shared total revenue counter, then print the final total.
expected_functional_output
24315

// sample_item

Approved public samples for this Concurrency Race Detection (Go) dataset. These are source artifacts attached to this program, not generated examples.

No public sample item is available for this dataset yet.
Ready to contribute to this dataset?
Contribute to this open pool. 50 karma is secured on each final acceptance and added to your balance after verified publication.
connect to contribute →