[Python-bugs-list] [ python-Bugs-668433 ] Abort with "negative ref count"

SourceForge.net noreply@sourceforge.net
Wed, 05 Feb 2003 19:56:44 -0800


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

Category: Python Interpreter Core
Group: Python 2.3
Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Walter Dörwald (doerwalter)
Assigned to: Guido van Rossum (gvanrossum)
>Summary: Abort with "negative ref count"

Initial Comment:
Python 2.3a1 and the current CVS version abort with the
following error message when executing the attached
test script:
Fatal Python error:
D:\Python-current\dist\src\Objects\descrobject.c:10
object at 007C3208 has negative ref count -1

This happens only in the debug build, both on Linux
(with configure --enable-unicode=ucs4 --with-pydebug
and 2.3a1) and on Windows (with the debug build and
current CVS).

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

>Comment By: Tim Peters (tim_one)
Date: 2003-02-05 22:56

Message:
Logged In: YES 
user_id=31435

Please open a new bug report then.  The cause of what 
you're seeing almost certainly has nothing to do with this 
bug report (for starters, you're nowhere near 
subtype_dealloc()), so mixing it in here is just going to 
cause ongoing confusion (as it already has).

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

Comment By: Skip Montanaro (montanaro)
Date: 2003-02-05 22:44

Message:
Logged In: YES 
user_id=44345

I was running a unittest script for the nascent csv module.  After posting,
I noticed that there was a bug in the test code (at the Python level), but 
the C code underneath seems fairly solid. (Based on Object Craft's csv
module which is pretty stable.)

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

Comment By: Tim Peters (tim_one)
Date: 2003-02-05 22:33

Message:
Logged In: YES 
user_id=31435

Skip, which program were you running?  I don't see any 
calls to dir() in any of the programs attached to this bug 
report, so I doubt that this bug report has anything to do 
with what you're seeing.

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

Comment By: Skip Montanaro (montanaro)
Date: 2003-02-05 22:22

Message:
Logged In: YES 
user_id=44345

I'm still seeing a negative ref count error with a fresh debug build after
cvs up...

(gdb) p *old_value
$1 = {
  _ob_next = 0xdbdbdbdb, 
  _ob_prev = 0xdbdbdbdb, 
  ob_refcnt = -606348326, 
  ob_type = 0xdbdbdbdb
}

#0  0x9001b52c in kill ()
#1  0x9005ceec in abort ()
#2  0x00012ad8 in Py_AtExit (func=0x4bfe0 <_Py_NegativeRefcount+88>) at Python/pythonrun.c:1334
#3  0x0004bfe0 in _Py_NegativeRefcount (fname=0x1266ac "Objects/dictobject.c", lineno=373, op=0x473258) at Objects/object.c:104
#4  0x0006cd90 in insertdict (mp=0x4da428, key=0x54ba28, hash=1490138787, value=0x134aac) at Objects/dictobject.c:373
#5  0x0006fddc in PyDict_Merge (a=0x4da428, b=0x4752d8, override=1) at Objects/dictobject.c:1142
#6  0x0006fb3c in PyDict_Update (a=0x4da428, b=0x4752d8) at Objects/dictobject.c:1102
#7  0x00051188 in merge_class_dict (dict=0x4da428, aclass=0x465ce0) at Objects/object.c:1641
#8  0x0005131c in merge_class_dict (dict=0x4da428, aclass=0x465d28) at Objects/object.c:1665
#9  0x00051ae4 in PyObject_Dir (arg=0x472278) at Objects/object.c:1796
#10 0x000cfca0 in builtin_dir (self=0x0, args=0x4c89a0) at Python/bltinmodule.c:396
#11 0x000c4470 in PyCFunction_Call (func=0x404df8, arg=0x4c89a0, kw=0x0) at Objects/methodobject.c:73
#12 0x000b8630 in call_function (pp_stack=0xbfffbb50, oparg=1) at Python/ceval.c:3285
#13 0x000b2e04 in eval_frame (f=0x4a1a38) at Python/ceval.c:2041
...

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

Comment By: Guido van Rossum (gvanrossum)
Date: 2003-02-05 17:46

Message:
Logged In: YES 
user_id=6380

Fixed in CVS, typeobject.c 2.203. Much thanks to Tim, who
understands the trashgcan code much better than I do.
Explanation is in the code. I checked that none of the three
examples breaks with the new code.

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

Comment By: Tim Peters (tim_one)
Date: 2003-02-05 17:08

Message:
Logged In: YES 
user_id=31435

Attached a very short test case.

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

Comment By: Guido van Rossum (gvanrossum)
Date: 2003-01-15 16:52

Message:
Logged In: YES 
user_id=6380

Bah. Trashcan code. :-(

OK, I'll look at it.

When I have time.

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

Comment By: Neal Norwitz (nnorwitz)
Date: 2003-01-15 16:37

Message:
Logged In: YES 
user_id=33168

8/6/2002 works without complaints, 8/8/2002 breaks, 8/7/2002
breaks with a different error message: 
Objects/typeobject.c:466: subtype_dealloc: Assertion
`g->gc.gc_refs != (-2)' failed.

All dates are American, ie, August, 6-8.  The change
corresponds to Object/typeobject.c:

8/6 - 2.165 works
8/7 - 2.166 assertion listed above
8/8 - 2.167 assertion in bug report (current)

Guido made all the changes, assigning to him. :-)

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

Comment By: Neal Norwitz (nnorwitz)
Date: 2003-01-15 15:37

Message:
Logged In: YES 
user_id=33168

I'm not running w/--enable-unicode=ucs4, but I still get the
problem.  I've simplified the test, but only a little so far. 
The problem did not affect 2.2.2, only 2.3.

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

Comment By: Neal Norwitz (nnorwitz)
Date: 2003-01-15 10:04

Message:
Logged In: YES 
user_id=33168

Walter, there's no file attached.

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

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