[New-bugs-announce] [issue42887] Multiple assignments of attribute "__sizeof__" will cause a segfault
Xinmeng Xia
report at bugs.python.org
Mon Jan 11 02:38:04 EST 2021
New submission from Xinmeng Xia <xiaxm at smail.nju.edu.cn>:
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(1000000):
mystr = mystr.__sizeof__()
print(mystr)
=========================
56
28
28
.......
28
28
Output: work well as expected.
program 2:
==========================
mystr = "hello123"
for x in range(1000000):
mystr = mystr.__sizeof__
print(mystr)
==========================
<built-in method __sizeof__ of builtin_function_or_method object at 0x7f04d3e0c220>
......
<built-in method __sizeof__ of builtin_function_or_method object at 0x7f04d3e0c4f0>
<built-in method __sizeof__ of builtin_function_or_method object at 0x7f04d3e0c540>
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 <report at bugs.python.org>
<https://bugs.python.org/issue42887>
_______________________________________
More information about the New-bugs-announce
mailing list