[Python-bugs-list] [ python-Bugs-783312 ] Serious mem leak in socket module

SourceForge.net noreply@sourceforge.net
Tue, 05 Aug 2003 13:35:47 -0700


Bugs item #783312, was opened at 2003-08-05 06:13
Message generated for change (Comment added) made by gottfried
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=783312&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: David Rushby (woodsplitter)
Assigned to: Nobody/Anonymous (nobody)
Summary: Serious mem leak in socket module

Initial Comment:
There are memory leaks in Python 2.3's
socketmodule.c:getsockaddrarg function.

In the AF_INET clause of that function's switch, the
PyArg_ParseTuple format was changed from
"si:getsockaddrarg" in 2.2 to "eti:getsockaddrarg" in
2.3; in the AF_INET6 clause, the format was changed
from "si|ii" in 2.2 to "eti|ii" in 2.3.

The memory leak occurs because the "s" extractor did
not allocate any memory that needed to be manually
freed, whereas "et" does, yet no provision was added to
free the newly allocated memory.

Looks like this bug was introduced in CVS revision 1.259:
 
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/Modules/socketmodule.c.diff?r1=1.258&r2=1.259

I've attached a test program that demonstrates the
leak, plus a patch to socketmodule.c in unified diff
format.

To me, this leak seems serious because it affects
virtually every Python program that uses the socket
module (getsockaddrarg is called by the socket.socket
methods bind, connect, connect_ex, and sendto).

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

Comment By: Gottfried Stauffenberg (gottfried)
Date: 2003-08-05 20:35

Message:
Logged In: YES 
user_id=838410

Since I have installed Python 2.3 Final (on Windows XP 
Professional) I have got a serious problem in my data 
uploading scripts to a SAP 7.4 Database on a different server. 
Python crashes with no traceback available and Windows 
notifies me of an serious program crash. The amount of data 
being send before the crash is variable, it can be anything 
between 100KB and 508KB of SQL INSERT statements 
(according to my application log file). I am not sure if the 
memory leak causes the program to crash, however this 
might be a possible explanation
There had been no problems in 2.2.3. with about 300 MB of 
sql statements.

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

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