homepage

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: PyList_Reverse fails with C Extensions
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: gvanrossum, tim.peters, whack
Priority: high Keywords:

Created on 2001年02月12日 16:45 by whack, last changed 2022年04月10日 16:03 by admin. This issue is now closed.

Messages (6)
msg3318 - (view) Author: Warren J. Hack (whack) Date: 2001年02月12日 16:45
The C API function 'PyList_Reverse()' causes a 'Segmentation
Fault(core dump)' when used under:
Python 2.0 (#1, Oct 27 2000, 09:38:44) [C] on sunos5
A simple C function was written to accept a Python list as
input and return it in reverse using 'PyList_Reverse()'.
When compiled under Python1.5.2, this code works flawlessly.
I use the function under Python in this manner:
Python 1.5.2 (#2, Apr 17 1999, 11:16:17) [C] on sunos5
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import casette
>>> shape = casette.casette([1,2,3,4])
>>> shape
[4, 3, 2, 1]
However, when compiled under Python2.0, it returns the
following error:
Python 2.0 (#1, Oct 27 2000, 09:38:44) [C] on sunos5
Type "copyright", "credits" or "license" for more information.
>>> import casette
>>> shape = casette.casette([1,2,3,4])
Segmentation fault (core dumped)
and exits from Python altogether. 
I can provide the test program (with Makefile) if it 
would help track down the bug. Any indication of the
cause of this bug or a work around would be appreciated.
msg3319 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2001年02月12日 20:21
Raised priority, assigned to me.
Offhand, looks like one of those cases where the worker function (listreverse) was changed to use PyArg_ParseTuple, but the API wrapper function (PyList_Reverse) passes NULL for args instead of an empty tuple. Boom. list.reverse() at Python level uses the worker function directly. so only an extension module would bump into this (PyList_Reverse isn't used anywhere within Python).
whack, this should get fixed for the 2.1b1 release. In the meantime, try invoking the reverse *method* on your list object.
msg3320 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2001年02月12日 21:43
I'll take care of this.
msg3321 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2001年02月12日 22:15
Related patches checked in:
_testcapimodule.c rev 1.2
 make sure PyList_Reverse doesn't blow up again
getargs.c rev 2.54
 assert args isn't NULL at the top of vgetargs1 instead of
 waiting for a NULL-pointer dereference at the end
msg3322 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2001年02月12日 22:21
All taken care of.
msg3323 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2001年02月12日 22:25
Change Resolution to Fixed. The fix is in listobject.c rev 2.92.
History
Date User Action Args
2022年04月10日 16:03:44adminsetgithub: 33912
2001年02月12日 16:45:01whackcreate

AltStyle によって変換されたページ (->オリジナル) /