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
{{ message }}
Repository navigation
testing: benchmark ReportMetric panic on concurrent call #54037
changed the title [-]affected/package: benchmark ReportMetric panic on concurrent call[/-][+]testing: benchmark ReportMetric panic on concurrent call[/+]on Jul 25, 2022
This looks like an incorrect use of ReportMetric though
I agree, especially given this sentence in its documentation:
ReportMetric overrides any previously reported value for the same unit.
Without a happens-before relationship between the calls to ReportMetric, the notion of “previously reported” is not well defined.
By convention, Go methods that mutate the state of a data-structure (as ReportMetric does) should be considered unsafe for concurrent use unless the documentation explicitly says otherwise.
Activity
Jack-Kingdom commentedon Jul 25, 2022
Copy panic log here
fatal error: concurrent map writes fatal error: concurrent map writes goroutine 1200 [running]: runtime.throw({0x4ae646?, 0x0?}) /usr/local/go-faketime/src/runtime/panic.go:992 +0x71 fp=0xc0001de740 sp=0xc0001de710 pc=0x431e91 runtime.mapassign_faststr(0x4ab755?, 0x2?, {0x4ab755, 0x2}) /usr/local/go-faketime/src/runtime/map_faststr.go:212 +0x39c fp=0xc0001de7a8 sp=0xc0001de740 pc=0x4114bc testing.(*B).ReportMetric(...) /usr/local/go-faketime/src/testing/benchmark.go:356 main.BenchmarkReportMetrics.func1() /tmp/sandbox1758758439/prog.go:7 +0x65 fp=0xc0001de7e0 sp=0xc0001de7a8 pc=0x48e665 runtime.goexit() /usr/local/go-faketime/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc0001de7e8 sp=0xc0001de7e0 pc=0x45cdc1 created by main.BenchmarkReportMetrics /tmp/sandbox1758758439/prog.go:12 +0x87 goroutine 1 [chan receive]: testing.(*B).doBench(0xc0000c4000) /usr/local/go-faketime/src/testing/benchmark.go:285 +0x7f testing.(*B).run(0xc0000c4000?) /usr/local/go-faketime/src/testing/benchmark.go:279 +0x6e testing.Benchmark(0x4b3f48) /usr/local/go-faketime/src/testing/benchmark.go:824 +0xf5 main.main() /tmp/sandbox1758758439/prog.go:18 +0x25 goroutine 59 [runnable]: main.BenchmarkReportMetrics(0xc0000c4000) /tmp/sandbox1758758439/prog.go:12 +0x87 testing.(*B).runN(0xc0000c4000, 0x2710) /usr/local/go-faketime/src/testing/benchmark.go:193 +0x102 testing.(*B).launch(0xc0000c4000) /usr/local/go-faketime/src/testing/benchmark.go:334 +0x1c5 created by testing.(*B).doBench /usr/local/go-faketime/src/testing/benchmark.go:284 +0x6c goroutine 1393 [runnable]: main.BenchmarkReportMetrics.func1() /tmp/sandbox1758758439/prog.go:6 created by main.BenchmarkReportMetrics /tmp/sandbox1758758439/prog.go:12 +0x87 goroutine 1391 [runnable]: main.BenchmarkReportMetrics.func1() /tmp/sandbox1758758439/prog.go:6 created by main.BenchmarkReportMetrics /tmp/sandbox1758758439/prog.go:12 +0x87 goroutine 1394 [runnable]: main.BenchmarkReportMetrics.func1() /tmp/sandbox1758758439/prog.go:6 created by main.BenchmarkReportMetrics /tmp/sandbox1758758439/prog.go:12 +0x87 goroutine 1277 [running]: goroutine running on other thread; stack unavailable created by main.BenchmarkReportMetrics /tmp/sandbox1758758439/prog.go:12 +0x87 goroutine 1392 [runnable]: main.BenchmarkReportMetrics.func1() /tmp/sandbox1758758439/prog.go:6 created by main.BenchmarkReportMetrics /tmp/sandbox1758758439/prog.go:12 +0x87 goroutine 1396 [runnable]: main.BenchmarkReportMetrics.func1() /tmp/sandbox1758758439/prog.go:6 created by main.BenchmarkReportMetrics /tmp/sandbox1758758439/prog.go:12 +0x87 goroutine 1395 [runnable]: main.BenchmarkReportMetrics.func1() /tmp/sandbox1758758439/prog.go:6 created by main.BenchmarkReportMetrics /tmp/sandbox1758758439/prog.go:12 +0x87 goroutine 1389 [runnable]: main.BenchmarkReportMetrics.func1() /tmp/sandbox1758758439/prog.go:6 created by main.BenchmarkReportMetrics /tmp/sandbox1758758439/prog.go:12 +0x87 goroutine 1388 [runnable]: main.BenchmarkReportMetrics.func1() /tmp/sandbox1758758439/prog.go:6 created by main.BenchmarkReportMetrics /tmp/sandbox1758758439/prog.go:12 +0x87 goroutine 1387 [runnable]: main.BenchmarkReportMetrics.func1() /tmp/sandbox1758758439/prog.go:6 created by main.BenchmarkReportMetrics /tmp/sandbox1758758439/prog.go:12 +0x87 goroutine 1386 [runnable]: main.BenchmarkReportMetrics.func1() /tmp/sandbox1758758439/prog.go:6 created by main.BenchmarkReportMetrics /tmp/sandbox1758758439/prog.go:12 +0x87 goroutine 1390 [runnable]: main.BenchmarkReportMetrics.func1() /tmp/sandbox1758758439/prog.go:6 created by main.BenchmarkReportMetrics /tmp/sandbox1758758439/prog.go:12 +0x87 goroutine 1385 [runnable]: main.BenchmarkReportMetrics.func1() /tmp/sandbox1758758439/prog.go:6 created by main.BenchmarkReportMetrics /tmp/sandbox1758758439/prog.go:12 +0x87 goroutine 1277 [running]: runtime.throw({0x4ae646?, 0x0?}) /usr/local/go-faketime/src/runtime/panic.go:992 +0x71 fp=0xc000186f40 sp=0xc000186f10 pc=0x431e91 runtime.mapassign_faststr(0x49a6e0, 0xc000012030, {0x4ab755, 0x2}) /usr/local/go-faketime/src/runtime/map_faststr.go:295 +0x38b fp=0xc000186fa8 sp=0xc000186f40 pc=0x4114ab testing.(*B).ReportMetric(...) /usr/local/go-faketime/src/testing/benchmark.go:356 main.BenchmarkReportMetrics.func1() /tmp/sandbox1758758439/prog.go:7 +0x65 fp=0xc000186fe0 sp=0xc000186fa8 pc=0x48e665 runtime.goexit() /usr/local/go-faketime/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc000186fe8 sp=0xc000186fe0 pc=0x45cdc1 created by main.BenchmarkReportMetrics /tmp/sandbox1758758439/prog.go:12 +0x87 Program exited.Jack-Kingdom commentedon Jul 25, 2022
try aquire lock on benchmark extra map write
#54038
seankhliao commentedon Jul 25, 2022
This looks like an incorrect use of ReportMetric though
[-]affected/package: benchmark ReportMetric panic on concurrent call[/-][+]testing: benchmark ReportMetric panic on concurrent call[/+]bcmills commentedon Jul 25, 2022
I agree, especially given this sentence in its documentation:
Without a happens-before relationship between the calls to
ReportMetric, the notion of “previously reported” is not well defined.By convention, Go methods that mutate the state of a data-structure (as
ReportMetricdoes) should be considered unsafe for concurrent use unless the documentation explicitly says otherwise.