[issue42887] Multiple assignments of attribute "__sizeof__" will cause a segfault

2021-01-11 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

This is a recursion problem, "mystr" will be equivalent to 
'hello123'.__sizeof__.__sizeof__. ...(100K repetition)... .__sizeof__.  The 
dealloc of "mystr" will cause recursive calls to tp_dealloc along the entire 
chain and that can exhaust the C stack.

--
nosy: +ronaldoussoren

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42887] Multiple assignments of attribute "__sizeof__" will cause a segfault

2021-01-11 Thread Christian Heimes


Christian Heimes  added the comment:

I can reproduce the issue. The stack trace is several hundred thousand (!) 
levels deep.

#0  _Py_DECREF (op=, lineno=514, filename=0x6570af 
"./Include/object.h")
at ./Include/object.h:448
#1  _Py_XDECREF (op=) at ./Include/object.h:514
#2  meth_dealloc (m=0x7fffe6070470) at Objects/methodobject.c:170
#3  0x00466a99 in _Py_Dealloc (op=) at 
Objects/object.c:2209
#4  0x005da2fa in _Py_DECREF (op=, lineno=514, 
filename=0x6570af "./Include/object.h") at ./Include/object.h:448
#5  _Py_XDECREF (op=) at ./Include/object.h:514
#6  meth_dealloc (m=0x7fffe60704d0) at Objects/methodobject.c:170
#7  0x00466a99 in _Py_Dealloc (op=) at 
Objects/object.c:2209
#8  0x005da2fa in _Py_DECREF (op=, lineno=514, 
filename=0x6570af "./Include/object.h") at ./Include/object.h:448
#9  _Py_XDECREF (op=) at ./Include/object.h:514
#10 meth_dealloc (m=0x7fffe6070530) at Objects/methodobject.c:170
#11 0x00466a99 in _Py_Dealloc (op=) at 
Objects/object.c:2209
#12 0x005da2fa in _Py_DECREF (op=, lineno=514, 
filename=0x6570af "./Include/object.h") at ./Include/object.h:448
#13 _Py_XDECREF (op=) at ./Include/object.h:514
#14 meth_dealloc (m=0x7fffe6070590) at Objects/methodobject.c:170
#15 0x00466a99 in _Py_Dealloc (op=) at 
Objects/object.c:2209
#16 0x005da2fa in _Py_DECREF (op=, lineno=514, 
filename=0x6570af "./Include/object.h") at ./Include/object.h:448
#17 _Py_XDECREF (op=) at ./Include/object.h:514
#18 meth_dealloc (m=0x7fffe60705f0) at Objects/methodobject.c:170
#19 0x00466a99 in _Py_Dealloc (op=) at 
Objects/object.c:2209
#20 0x005da2fa in _Py_DECREF (op=, lineno=514, 
filename=0x6570af "./Include/object.h") at ./Include/object.h:448
#21 _Py_XDECREF (op=) at ./Include/object.h:514
#22 meth_dealloc (m=0x7fffe6070650) at Objects/methodobject.c:170
...
#509737 _Py_XDECREF (op=) at ./Include/object.h:514
#509738 meth_dealloc (m=0x7fffe54ca6b0) at Objects/methodobject.c:170
#509739 0x00466a99 in _Py_Dealloc (op=) at 
Objects/object.c:2209
#509740 0x005da2fa in _Py_DECREF (op=, lineno=514, 
filename=0x6570af "./Include/object.h") at ./Include/object.h:448
#509741 _Py_XDECREF (op=) at ./Include/object.h:514
#509742 meth_dealloc (m=0x7fffe54ca710) at Objects/methodobject.c:170
#509743 0x00466a99 in _Py_Dealloc (op=) at 
Objects/object.c:2209
#509744 0x005da2fa in _Py_DECREF (op=, lineno=514, 
filename=0x6570af "./Include/object.h") at ./Include/object.h:448
#509745 _Py_XDECREF (op=) at ./Include/object.h:514
#509746 meth_dealloc (m=0x7fffe54ca770) at Objects/methodobject.c:170

...

--
nosy: +christian.heimes

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42887] Multiple assignments of attribute "__sizeof__" will cause a segfault

2021-01-10 Thread Xinmeng Xia

New submission from Xinmeng Xia :

In the following program 1, method  "__sizeof__()" is called and assigned 
multiple times. The program can work well on Python 3.10. However if I change 
"__sizeof__()" to  "__sizeof__".  Then a segmentation fault is reported. I 
think something wrong for the parser when dealing build-in attribute assignment.



program 1: 
=
mystr  = "hello123"
for x in range(100):
mystr = mystr.__sizeof__()
print(mystr)
=
56
28
28
...
28
28

Output: work well as expected.


program 2: 
==
mystr = "hello123"
for x in range(100):
mystr = mystr.__sizeof__
print(mystr)
==

..


Segmentation fault (core dumped)

Expected output: no segfault.

--
components: Interpreter Core
messages: 384797
nosy: xxm
priority: normal
severity: normal
status: open
title: Multiple assignments of attribute "__sizeof__" will cause a segfault
type: crash
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com