Fails not necessarily because xgselect.c is wrong, but rather because channel-recv blocks on a mutex before channel-send can get its act together. This was hard for all to discern because OP seemed to have gone out of his way to obfuscate his "minimum" example. #4. What #3 probably intended, succeeds after patch in #1.