[Python-bugs-list] [ python-Bugs-616716 ] Bug in PyErr_SetExcFromWindows...?

noreply@sourceforge.net noreply@sourceforge.net
Thu, 03 Oct 2002 08:58:53 -0700


Bugs item #616716, was opened at 2002-09-30 15:44
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=616716&group_id=5470

Category: Python Interpreter Core
Group: Platform-specific
Status: Open
Resolution: None
Priority: 5
Submitted By: Tim Peters (tim_one)
Assigned to: Mark Hammond (mhammond)
Summary: Bug in PyErr_SetExcFromWindows...?

Initial Comment:
On Win98SE I was running ZEO tests (a Zope thing) in 
a loop for hours, under current CVS.  It eventually 
blew up with a memory fault.

select() returned SOCKET_ERROR, and then 
WSAGetLastError() returned WSAEINTR.  That's all 
normal here.

Python calls

PyErr_SetExcFromWindowsErr(SelectError, 
WSAGetLastError());

and WSAEINTR==10004 is the second argument.

This *eventually* blew up in MS's strlen() function, 
reached via a long chain of calls starting at 
PyErr_SetExcFromWindowsErrWithFilename's

    v = Py_BuildValue("(is)", err, s);

The problem is here:  s makes no sense.  It's a tiny 
integer (0x2714), not a legit char*. In fact, 0x2714 
== 10004, the error code passed in!

Now the local vrbl len is 0 at this point, and len is the 
return value from FormatMessage().  To my eyes, this 
means FormatMessage() failed, but the code doesn't 
appear to check for failure from that function.  If 
FormatMessage() does fail, I don't see a guarantee in 
the MS docs that &s will get a sensible value stored 
into it, in which case the value of s is just stack trash 
(and it's quite plausible that 10004 is sitting on the 
stack at this point).

Make sense?  Looks to me like we have to check for 
failure in FormatMessage.  Unfortunately, I have no 
idea why this call would fail.  It's plausible that running 
ZEO tests in a loop for hours causes Win98SE to run 
out of some sort of internal resource, and I've never 
been able to run ZEO tests for hours on any flavor of 
Windows before.

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

>Comment By: Tim Peters (tim_one)
Date: 2002-10-03 11:58

Message:
Logged In: YES 
user_id=31435

Go for it, Mark!  Looks fine to me.

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

Comment By: Mark Hammond (mhammond)
Date: 2002-10-03 02:51

Message:
Logged In: YES 
user_id=14198

I agree it is probably out of memory.

Attaching a patch that still attempts to give something
useful in this situation.  If no objections I will check it
in tomorrow (or sooner if someone agrees :)

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

Comment By: Guido van Rossum (gvanrossum)
Date: 2002-09-30 15:54

Message:
Logged In: YES 
user_id=6380

Maybe it's run out of memory? That's what usually kills ZEO
tests on Linux in the end.

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

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