[pypy-issue] [issue1238] "bad write retry" from ssl sockets
Ben Darnell
tracker at bugs.pypy.org
Sun Aug 19 08:12:39 CEST 2012
New submission from Ben Darnell <ben at bendarnell.com>:
Writing to an SSL socket in pypy (1.9, tested on mac) sometimes fails with a "bad
write retry" message, when the same code succeeds in cpython. I believe this is
because with pypy's GC, objects may be moved around, so the address of a str
object may change (if I'm wrong on this point please correct me). In non-blocking
mode, openssl requires by default that the same buffer be used for repeated write
calls. In cpython this can be done by ensuring that the same string object be
reused (see e.g
https://github.com/facebook/tornado/blob/master/tornado/iostream.py#L527), but for
pypy that doesn't work, so the simplest workaround is to disable this sanity check
by setting SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER on the ssl context.
Related cpython issue: http://bugs.python.org/issue8240
It's difficult to make a minimal test case since the bug depends on both socket
buffering and garbage collection, but
https://github.com/facebook/tornado/blob/master/tornado/test/iostream_test.py#L266
seems to trigger it reliably.
----------
messages: 4658
nosy: bdarnell, pypy-issue
priority: bug
status: unread
title: "bad write retry" from ssl sockets
________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1238>
________________________________________
More information about the pypy-issue
mailing list