[Python-bugs-list] [ python-Bugs-681902 ] Negative refcount abort

SourceForge.net noreply@sourceforge.net
Thu, 06 Feb 2003 16:34:30 -0800


Bugs item #681902, was opened at 2003-02-06 15:26
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=681902&group_id=5470

Category: Python Interpreter Core
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Skip Montanaro (montanaro)
Assigned to: Nobody/Anonymous (nobody)
Summary: Negative refcount abort

Initial Comment:
I originally thought this was the same as #668433 (thinking there
could only be one negative refcount bug at a time).  Then I thought
perhaps it was the same as #681122, but removing dir() from the
test code seemed to have no effect.  So I conclude there is another
negative refcount bug (or a bug in the underlying extension
module) running around in the CVS HEAD, at least when configured with --with-pydebug.  My platform is Mac OS X, vanilla Unix-style
build.

I will attach a short test script.  Unfortunately, it's a unit test for
the still developing csv module.  I added a cvs tag so you can check
it out and install it easily enough though.

The underlying code is in .../head/nondist/sandbox/csv.  If you
check it out using the tag "refcount", you'll get the version which
barfs.

The symptom is that a reference to a classic class object appears to
be held by the module after the class has been released.  This class
is only manipulated from the Python level.  The underlying _csv
extension module doesn't refer to it as far as I know.

To tickle the problematic behavior, leave the code alone.  It contains
a typo.  The "restfields" keyowrd parameter ought to be "restfield".
Correct the error and the problem goes away.

(I guess the moral of the story is you should never write code with
bugs. ;-)

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

>Comment By: Neal Norwitz (nnorwitz)
Date: 2003-02-06 19:34

Message:
Logged In: YES 
user_id=33168

This crashes (the ref count goes down inappropriately):
  _csv.parser(lineterminator='\r\n', restfields='_rest')

This is ok:
  _csv.parser(restfields='_rest')

Attaching output from valgrind.  It doesn't help me, but may
help someone else.

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

Comment By: Neal Norwitz (nnorwitz)
Date: 2003-02-06 18:06

Message:
Logged In: YES 
user_id=33168

My current guess is a problem in csv.  If you repeat this line:

  csv.reader("1", dialect="excel", fieldnames=["f1"],
restfields="_rest")

The ref count goes backwards  If I repeat this one line, the
interpreter crashes the third time.

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

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