In _PyAsyncIoStreamProtocol.write_loop(), memoryview objects pointing to C++ message memory were passed directly to transport.write(). Since transport.write() is non-blocking and only queues data for later transmission, the memoryview could reference freed memory after fulfill() was called. This caused message corruption when pipelining RPC calls with payloads larger than ~4000 bytes, as the C++ message memory would be freed before asyncio had a chance to transmit the data. The fix copies the data to Python bytes objects before passing to transport.write(), ensuring the data remains valid until asyncio transmits it. Includes regression test that verifies large payload integrity with both sequential and pipelined RPC calls.
4.1 KiB
4.1 KiB