golang: Fix race in chan._tryrecv
For buffered channel _tryrecv, on success, was unlocking ch._mu too early - before accessing ch._dataq with ch._dataq.append(). Without the fix, newly added test breaks as e.g. golang/golang_test.py::test_chan_buf_recv_vs_tryrecv_race Exception in thread Thread-3: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "/home/kirr/src/tools/go/pygolang-master/golang/golang_test.py", line 317, in _ assert (_, _rx) == (1, None), ('i%d' % i) AssertionError: i30 assert (0, None) == (1, None) At index 0 diff: 0 != 1 Full diff: - (0, None) ? ^ + (1, None) ? ^
Showing
Please register or sign in to comment