Skip to content

context: misuse of sync.Cond in ExampleAfterFunc_cond #62180

Closed
@bcmills

Description

@bcmills
#!watchflakes
post <- `^goroutine \d+ \[sync\.Cond\.Wait, .*\]:` && `^context_test\.ExampleAfterFunc_cond`

(Pulled out from #62165 (comment).)

https://build.golang.org/log/6040fd74316c6fe15adcca97b7b68a471db61575:

goroutine 1 [sync.Cond.Wait, 14 minutes]:
runtime.gopark(0x40002800e0?, 0x40000021a0?, 0x88?, 0x59?, 0xc731c?)
	/home/gopher/build/go/src/runtime/proc.go:398 +0xc8 fp=0x4000235940 sp=0x4000235920 pc=0x4a178
runtime.goparkunlock(...)
	/home/gopher/build/go/src/runtime/proc.go:404
sync.runtime_notifyListWait(0x40000ce010, 0x0)
	/home/gopher/build/go/src/runtime/sema.go:527 +0x150 fp=0x4000235990 sp=0x4000235940 pc=0x78580
sync.(*Cond).Wait(0x40000ce000)
	/home/gopher/build/go/src/sync/cond.go:70 +0xcc fp=0x40002359d0 sp=0x4000235990 pc=0x8093c
context_test.ExampleAfterFunc_cond.func1({0x1d3bf8, 0x40000b00e0}, 0x40000ce000)
	/home/gopher/build/go/src/context/example_test.go:131 +0xa8 fp=0x4000235a30 sp=0x40002359d0 pc=0x1469d8
context_test.ExampleAfterFunc_cond()
	/home/gopher/build/go/src/context/example_test.go:142 +0x120 fp=0x4000235ab0 sp=0x4000235a30 pc=0x13f190
testing.runExample({{0x19d3c8, 0x15}, 0x1a78e0, {0x19f322, 0x1a}, 0x0})
	/home/gopher/build/go/src/testing/run_example.go:63 +0x244 fp=0x4000235bb0 sp=0x4000235ab0 pc=0xd58f4
testing.runExamples(0x1d4c78?, {0x2ca040, 0x7, 0x25?})
	/home/gopher/build/go/src/testing/example.go:40 +0x104 fp=0x4000235c50 sp=0x4000235bb0 pc=0xd1ad4
testing.(*M).Run(0x400011a280)
	/home/gopher/build/go/src/testing/testing.go:1927 +0x5e4 fp=0x4000235ea0 sp=0x4000235c50 pc=0xdb404
main.main()
	_testmain.go:149 +0x1a8 fp=0x4000235f30 sp=0x4000235ea0 pc=0x147888
runtime.main()
	/home/gopher/build/go/src/runtime/proc.go:267 +0x2b8 fp=0x4000235fd0 sp=0x4000235f30 pc=0x49d18
runtime.goexit()
	/home/gopher/build/go/src/runtime/asm_arm64.s:1197 +0x4 fp=0x4000235fd0 sp=0x4000235fd0 pc=0x7c4c4

This test / example was added in https://go.dev/cl/482695 (attn @dneil @Sajmani) for #57928; it's new as of Go 1.21.

Given that this example involves a sync.Cond and a context.WithTimeout, I'm about 98% confident that the bug is in the example somewhere. 😅

Metadata

Metadata

Assignees

Labels

DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.TestingAn issue that has been verified to require only test changes, not just a test failure.

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions