This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: refcount problem in syslog
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: dsm001, rhettinger
Priority: normal Keywords:

Created on 2004-12-16 16:36 by dsm001, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
syslog.diff rhettinger, 2004-12-16 16:54 Refcount patch
Messages (4)
msg23724 - (view) Author: DSM (dsm001) Date: 2004-12-16 16:36
Refcount problem in syslog.openlog, dating back awhile:

Python 2.5a0 (#10, Dec 15 2004, 19:53:33) 
[GCC 3.3.3 (Debian 20040401)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> import syslog
[25538 refs]
>>> syslog.openlog('a')
[25539 refs]
>>> syslog.openlog(0)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: ident string [, logoption [, facility]]
[25575 refs]
>>> syslog.openlog(0)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: ident string [, logoption [, facility]]
[25574 refs]
>>> syslog.openlog(0)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: ident string [, logoption [, facility]]
[25573 refs]

[etc..]

>>> syslog.openlog(0)
Fatal Python error:
/home/doug/cvsroot/python/dist/src/Modules/syslogmodule.c:62
object at 0x402d75d8 has negative ref count -4
Aborted

ISTM there's a misplaced Py_XDECREF in syslog_openlog.
 It's fine as long as no log is open, but after that
each failed PyArg_ParseTuple costs you a ref.
msg23725 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-12-16 16:54
Logged In: YES 
user_id=80475

See if the attached patch solves your problem.
Also, please run the full test suite.
(I'm on Windows and cannot exercise this code.)
msg23726 - (view) Author: DSM (dsm001) Date: 2004-12-16 18:51
Logged In: YES 
user_id=1175690

Patch works after correcting typo (*new_S_ident_0 should be
*new_S_ident_o); openlog() and closelog() both seem to
refcount as expected; and passes make test without difficulty.
msg23727 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-12-16 23:52
Logged In: YES 
user_id=80475

Fixed.
See Modules/sysmodule.c 2.20


Thanks for submitting the bug report and testing the patch.
History
Date User Action Args
2022-04-11 14:56:08adminsetgithub: 41331
2004-12-16 16:36:51dsm001create