> Short story: bytearray and array.array by construction allow user code to > reallocate their internal memory buffer. But a raw pointer to the said buffer > can also be obtained by another thread, and used after releasing the GIL (for > CPU-intensive operations like compression). As a consequence, the interpreter > crashes. > > Was it envisioned?
I guess this wasn't considered. For t#, there is a comment from Travis that it really shouldn't release the buffer yet, but it does, anyway. I propose that new codes s*, t*, w* are added, and that s#,t#,w# refuses objects which implement a releasebuffer procedure (alternatively, s# etc might be removed altogether right away). Users of s* then need to pass in a Py_Buffer view pointer that gets filled, and need to explicitly release the buffer. For convenience, it might help if the Py_buffer structure includes a borrowed PyObject* to the underlying object, along with a PyBuffer_Release procedure/macro. Regards, Martin _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com