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: classmethod().__get__() segfault
Type: Stage:
Components: Interpreter Core Versions: Python 2.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: arigo, gvanrossum, mwh
Priority: high Keywords:

Created on 2002-03-10 15:19 by arigo, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
cm.diff mwh, 2002-03-17 20:11 idiot fix
Messages (6)
msg9609 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2002-03-10 15:19
Calling the __get__ method of a classmethod object 
with a single argument causes a segmentation fault in 
the interpreter :

  def f(): pass
  classmethod(f).__get__(0)

This is caused by an internal inconsistency between 
the __get__ wrapper function in C that calls the 
tp_descr_get slot with a NULL third argument in this 
case and some tp_descr_get slot implementations (like 
the classmethods') which dereference it with no check.
msg9610 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2002-03-16 17:37
Logged In: YES 
user_id=6656

Oopsie, we'll have this one fixed for 2.2.1.

I think you mangaged to submit this bug during a time when
bug email was somewhat hosed...
msg9611 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2002-03-17 20:11
Logged In: YES 
user_id=6656

Guido, is this fix sane?

No other implementation of tp_descr_get seems to be at risk.
msg9612 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-03-17 22:10
Logged In: YES 
user_id=6380

Alas, it looks I can still force a segfault by calling the
resulting unbound method with a bogus argument. I'll look
into this now.
msg9613 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-03-17 23:08
Logged In: YES 
user_id=6380

Alas, not tonight. Tomorrow morning for sure.
msg9614 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-03-18 03:10
Logged In: YES 
user_id=6380

Fixed it, both in 2.2.1 branch and in 2.3 trunk. The "idiot
fix" (not my words) below didn't quite do it, but letting
type default to obj->ob_type does the trick.
History
Date User Action Args
2022-04-10 16:05:05adminsetgithub: 36236
2002-03-10 15:19:08arigocreate