[Python-bugs-list] [ python-Bugs-781592 ] OverflowError exception in garbage collector

SourceForge.net noreply@sourceforge.net
Fri, 01 Aug 2003 11:30:50 -0700


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

Category: Python Interpreter Core
Group: Python 2.3
>Status: Closed
>Resolution: Accepted
Priority: 7
Submitted By: Peter Kwan (dipsypo82)
Assigned to: Nobody/Anonymous (nobody)
Summary: OverflowError exception in garbage collector

Initial Comment:
It is known that Python 2.3 will issue warnings for 
hex/oct literals > sys.maxint. According to 
documentation, one get around is to append "L" to the 
literal to make it explicitly long.

For example, instead of 0x80ff3366, use 0x80ff3366L.

However, the long value will cause Python 2.3 
terminates with the following fatal error:

Exception exceptions.OverflowError: 'long int too large to 
convert to int' in 'garbage collection' ignored
Fatal Python error: unexpected exception during garbage 
collection
 
abnormal program termination

The Python code under testing is passing the above 
constant to a C routine as an argument. The C routine 
calls:
 
//convert the given argument to Long in case 
//it is not already Long
PyObject *longObj = PyNumber_Long(argument);
 
//get the value of the Python Long variable
long ret = PyLong_AsLong(longObj);
 
The error occur shortly after the above code (during 
subsequent garbage collection?). It does not occur if I 
used 0x80ff3366 instead of 0x80ff3366L. Also, it does 
not occur if the second line of C code is commented out. 

The error also does not occur in Python 1.5.2 up to 
Python 2.2, no matter I use 0x80ff3366 or 0x80ff3366L.

The code is running on Windows 2000.


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

>Comment By: Peter Kwan (dipsypo82)
Date: 2003-08-02 02:30

Message:
Logged In: YES 
user_id=835585

Thanks a lot for your help. I think you are right.

Actually, I do check for error return for the PyNumber_Long 
call, but I just omit them in the bug report for simplicity. I do 
not check for error for PyLong_AsLong because this API 
cannot return error when I wrote this code in the past (at the 
time of Python 1.5.x). I checked the latest Python 
documentation and found that it now can return error. 
Apparently, in Python 2.3, I need to use the new Python 2.3 
API PyLong_AsUnsignedLongMask instead, which is equivalent 
to the old PyLong_AsUnsignedLong.

So I think we can declare this bug closed - reason: this is not 
a bug.


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

Comment By: Neil Schemenauer (nascheme)
Date: 2003-08-02 01:12

Message:
Logged In: YES 
user_id=35752

It sounds as though you are not checking return values. 
Both PyNumber_Long() and PyLong_AsLong() can return an
error.  If your code does not check for the error then it
will be detected by some later code.

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

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