[Python-bugs-list] [ python-Bugs-544995 ] zlib crash on win32

noreply@sourceforge.net noreply@sourceforge.net
Wed, 17 Apr 2002 18:36:03 -0700


Bugs item #544995, was opened at 2002-04-17 00:17
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=544995&group_id=5470

Category: Python Library
Group: Python 2.2.1 candidate
Status: Open
Resolution: None
Priority: 5
Submitted By: Andrew Bennetts (spiv)
Assigned to: Nobody/Anonymous (nobody)
Summary: zlib crash on win32

Initial Comment:
On Win2k:

>>> import zlib
>>> c = zlib.compressobj()
>>> c.flush()
'x\x9c\x03\x00\x00\x00\x00\x01'
>>> c.flush()    # This crashes.

This occurs both from the command line and from IDLE.

I cannot reproduce this on Linux (it just raises a
zlib.error, as you would expect).

----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2002-04-17 21:36

Message:
Logged In: YES 
user_id=31435

Andrew, right, I understood the bug report.  The question 
I'm wondering about is why you don't see a problem on 
Linux, because the code Mark patched has nothing to do with 
Windows specifically.  Your bug report didn't say which 
version of zlib you were using, so that was a possibly 
relevant difference -- turns out it wasn't.

----------------------------------------------------------------------

Comment By: Mark Hammond (mhammond)
Date: 2002-04-17 21:29

Message:
Logged In: YES 
user_id=14198

Oh ye of little faith <wink>

Looks to me like a Python CVS problem.  My Linux build also 
crashes:

Python 2.3a0 (#13, Apr  6 2002, 13:45:37)
[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-79)] on linux2
Type "help", "copyright", "credits" or "license" for more 
information.
>>> import zlib
>>> c = zlib.compressobj()
>>> c.flush()
'x\x9c\x03\x00\x00\x00\x00\x01'
>>> c.flush()
Segmentation fault (core dumped)

My patch also fixes it :)

A quick scan of CVS shows the following checkin responsible:

----------------------------
Revision : 2.49
Date : 2001/10/16 23:2:32
Author : 'jhylton'
State : 'Exp'
Lines : +115 -169
Description :
Simplify and fix error handling for most cases.


----------------------------------------------------------------------

Comment By: Andrew Bennetts (spiv)
Date: 2002-04-17 21:13

Message:
Logged In: YES 
user_id=50945

Tim, I'm using Debian's 1.1.4 on Linux, but Linux is working
fine (perhaps you misread my bug report, which was rather
terse?).  The example I gave segfaults on Windows 2000.  It
should instead raise a zlib.error, which it does on Linux. 
The docs say that you cannot do anything useful with a
compressobj opened in mode Z_FINISH (the default) after
calling flush, so the zlib.error is expected.

I can't test Mark's patch, but at a glance it looks good.

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2002-04-17 21:07

Message:
Logged In: YES 
user_id=31435

Mark, looks good to me, but I'd really like to see someone 
on Linux dig into this too.  Is this an ancient bug that 
just never surfaced before?  Or does it have something to 
do with moving to zlib 1.1.4 on Windows?

----------------------------------------------------------------------

Comment By: Mark Hammond (mhammond)
Date: 2002-04-17 02:56

Message:
Logged In: YES 
user_id=14198

Crashes for me too.  Attaching patch to zlibmodule, and
addition to test suite that demonstrates the crash.

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2002-04-17 00:43

Message:
Logged In: YES 
user_id=31435

Andrew, which version of zlib were you using on Linux?  
Windows ships with zlib 1.1.4, which is a very recent 
release produced by the zlib folks to plug a zlib security 
hole.  On Linux we don't ship any version of zlib, so you 
get whatever zlib happens to be sitting on your box.  If 
you haven't done something to upgrade your Linux zlib 
version, you probably have 1.1.3.  Can you check?  (And no, 
sorry, I don't know how you can check -- but since you're 
closer to your box than I am, you've got a better shot than 
I do <wink>).

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=544995&group_id=5470