Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
Closed
Description
When specializingLOAD_ATTR_SLOT
, we don't check whether the given member descriptor is valid for the type we got it from.
Here is a problematic example, where one class "borrows" a slot from another:
>>>classClass:...__slots__= ("slot",)...>>>classSneaky:...borrowed=Class.slot...>>>deff(o):...returno.borrowed...>>>o=Sneaky()
The unspecialized code behaves correctly:
>>>f(o)Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>File"<stdin>",line2,infTypeError:descriptor'slot'for'Class'objectsdoesn't apply to a 'Sneaky'object
However, the specialized code crashes, since it is accessing memory past the end of the object:
>>>f(o)Segmentationfault
We can fix this by performing the same check that the member descriptor performs (PyObject_TypeCheck(obj, descr->d_type)
) when specializing.
Metadata
Metadata
Assignees
Labels
Projects
Status
Done