This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author malin
Recipients malin
Date 2020-09-07.03:14:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1599448486.98.0.401518384343.issue41735@roundup.psfhosted.org>
In-reply-to
Content
The code in zlib module:

    self->zst.next_in = data->buf;  // set next_in
    ...
    ENTER_ZLIB(self);   // acquire thread lock

`self->zst` is a `z_stream` struct defined in zlib, used to record states of a compress/decompress stream:

    typedef struct z_stream_s {
        Bytef    *next_in;  /* next input byte */
        uInt     avail_in;  /* number of bytes available at next_in */
        uLong    total_in;  /* total number of input bytes read so far */

        Bytef    *next_out; /* next output byte will go here */
        uInt     avail_out; /* remaining free space at next_out */
        uLong    total_out; /* total number of bytes output so far */
        
        ... // Other states
    } z_stream;

Setting `next_in` before acquiring the thread lock may mix up compress/decompress state in other threads.

Moreover, modify `ENTER_ZLIB` macro, don't release the GIL when the thread lock can be acquired immediately. This behavior is the same as the bz2/lzma modules.
History
Date User Action Args
2020-09-07 03:14:47malinsetrecipients: + malin
2020-09-07 03:14:46malinsetmessageid: <1599448486.98.0.401518384343.issue41735@roundup.psfhosted.org>
2020-09-07 03:14:46malinlinkissue41735 messages
2020-09-07 03:14:46malincreate