Closed mewmew closed 7 years ago
With the following patch to mainthread/mainthread.go, I can no longer reproduce the race condition. Before I could reproduce it with high confidence running for less than 30 seconds. Now, I've had it run for 5 minutes and no race condition noticed.
diff --git a/mainthread.go b/mainthread.go
index ef29ed9..04e3347 100644
--- a/mainthread.go
+++ b/mainthread.go
@@ -60,11 +60,12 @@ func CallNonBlock(f func()) {
// Call queues function f on the main thread and blocks until the function f finishes.
func Call(f func()) {
checkRun()
+ done := make(chan struct{})
callQueue <- func() {
f()
- respChan <- struct{}{}
+ done <- struct{}{}
}
- <-respChan
+ <-done
}
// CallErr queues function f on the main thread and returns an error returned by f.
I've been playing around with integrating pixel into a game lately, and stumbled upon what looks like a race condition; a nil-pointer dereference in
glpixel.GLTriangle.Len
.To identify the cause of the race condition, I added a few debug print statements in
gltriangle.go
:Right before the nil-pointer dereference, the output looks as follows:
Has anyone else encountered this?