-
Notifications
You must be signed in to change notification settings - Fork 47
Description
Problem
When calling exec.Command.Run(), it hung up occasionally.
exec.Command("...").Run()
Investigate
We injected some debug output codes to llgo runtime, and found these situations.
When it hung up, it prints
recv {2 <nil>}
after minus {1 <nil>}
sent back {1 <nil>}
recv {1 <nil>}
after minus {0 <nil>}
recv {2 <nil>}
recv {2 <nil>}
after minus {1 <nil>}
after minus {1 <nil>}
sent back {1 <nil>}
sent back {1 <nil>}
In this output, we found the second recv is not expected.
We suspected that there's something wrong about channel implement.
So we injected some debug codes to z_chan.go
And we found these strange output, in these codes, Cond.Wait should wait for someone, however, it skips waiting, and keep busy waitting.
Then, we printed the output of Wait, and found it returnsEINVAL, which means we passed an uninitiated mutex to it, casuing it busy waiting.
It also explains the reason why the result of recv is wrong, because the uninitiated mutex cannot protect critical sections causing the data racy.
Conclusion
The mutex of channel is uninitiated.


