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.

classification
Title: zlibmodule cannot handle Z_VERSION_ERROR zlib error
Type: crash Stage: resolved
Components: Extension Modules Versions: Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: nadeem.vawda Nosy List: nadeem.vawda, python-dev, rmtew
Priority: normal Keywords: patch

Created on 2011-08-25 05:21 by rmtew, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
zlibmodule.patch rmtew, 2011-08-25 07:00
Messages (6)
msg142954 - (view) Author: (rmtew) Date: 2011-08-25 05:21
zlibmodule.c calling inflateInit2 and deflateInit2 will subsequently proceed to crash in the case where these functions return Z_VERSION_ERROR.

zlib implementation note:

When you compile against zlib, several functions (actually macros) like inflateInit2 and deflateInit2 compile the version of zlib you are compiling against into the actual call of the underlying real zlib API function.

Our situation:

We are compiling Python as a static library.  When we link Python against our main project,  it links against the version of zlib used by that main project.  The version numbers are different, and rather than getting a nice exception we get a crash.

Expected result:

Proper error handling in zlibmodule.c, and not crash.  Unhandled errors in zlibmodule.c are passed into the custom function zlib_error which looks at the msg field of the zst struct.  In the case of Z_VERSION_ERROR the msg field is not initialised and a crash will result from use of the nonsense value in msg.
msg142958 - (view) Author: (rmtew) Date: 2011-08-25 07:00
Attached is a patch to fix the issue, generated using "p4 diff -du" which should hopefully be usable.
msg142962 - (view) Author: Nadeem Vawda (nadeem.vawda) * (Python committer) Date: 2011-08-25 08:19
Thanks for the bug report and patch. I'll take a look at it over the weekend.
msg143093 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-08-28 09:30
New changeset ba5000307b5d by Nadeem Vawda in branch '2.7':
Issue #12839: Fix crash in zlib module due to version mismatch.
http://hg.python.org/cpython/rev/ba5000307b5d

New changeset cc9e794bf94f by Nadeem Vawda in branch '3.2':
Issue #12839: Fix crash in zlib module due to version mismatch.
http://hg.python.org/cpython/rev/cc9e794bf94f

New changeset b384231df332 by Nadeem Vawda in branch 'default':
Merge: #12839: Fix crash in zlib module due to version mismatch.
http://hg.python.org/cpython/rev/b384231df332
msg143125 - (view) Author: Nadeem Vawda (nadeem.vawda) * (Python committer) Date: 2011-08-28 21:09
Done. Once again, thanks for the report and the patch!
msg143486 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-09-04 06:56
New changeset 2fb00b6ed17c by Nadeem Vawda in branch '3.2':
Issue #12839: Fix crash in zlib module due to version mismatch.
http://hg.python.org/cpython/rev/2fb00b6ed17c
History
Date User Action Args
2022-04-11 14:57:21adminsetgithub: 57048
2011-09-04 06:56:36python-devsetmessages: + msg143486
2011-08-28 21:09:56nadeem.vawdasetstatus: open -> closed
resolution: fixed
messages: + msg143125

stage: resolved
2011-08-28 09:30:03python-devsetnosy: + python-dev
messages: + msg143093
2011-08-25 08:19:15nadeem.vawdasetnosy: + nadeem.vawda
messages: + msg142962

assignee: nadeem.vawda
components: + Extension Modules, - None
2011-08-25 07:00:49rmtewsetfiles: + zlibmodule.patch
keywords: + patch
messages: + msg142958
2011-08-25 05:21:49rmtewcreate