[issue42887] 100000 assignments of .__sizeof__ cause a segfault on del

2021-01-19 Thread STINNER Victor
Change by STINNER Victor : -- nosy: +vstinner ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.py

[issue42887] 100000 assignments of .__sizeof__ cause a segfault on del

2021-01-19 Thread Mark Shannon
Mark Shannon added the comment: It won't solve the problem. Maybe make it would make it easier to avoid the segfault, but some sort of recursion/overflow check is needed. It might make the use of the trashcan cheaper, as it only need be used when stack space is running low. Ultimately, the

[issue42887] 100000 assignments of .__sizeof__ cause a segfault on del

2021-01-19 Thread Terry J. Reedy
Terry J. Reedy added the comment: Mark, would your proposal in PEP-651 fix this case? -- nosy: +Mark.Shannon ___ Python tracker ___ ___

[issue42887] 100000 assignments of .__sizeof__ cause a segfault on del

2021-01-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Yes, there is an overhead of using the trashcan mechanism. This is why it is only used in data collections, because it is expected that your data can contain arbitrary long chains of links. There is many ways to create arbitrary long chains with other obje

[issue42887] 100000 assignments of .__sizeof__ cause a segfault on del

2021-01-18 Thread Ronald Oussoren
Ronald Oussoren added the comment: Note that there is a way to avoid this crash using the trashcan API (see the use of Py_TRASHCAN_BEGIN in various implementation). This API is generally only used for recursive data structures and because it has a performance cost (based on what I've read i

[issue42887] 100000 assignments of .__sizeof__ cause a segfault on del

2021-01-15 Thread William Pickard
William Pickard added the comment: Jumping in here to explain why '__class' doesn't crash when '__sizeof__' does: When '__class__' is fetched, it returns a new reference to the object's type. When '__sizeof__' is fetched on the otherhand, a new object is allocated on the heap ('types.MethodT

[issue42887] 100000 assignments of .__sizeof__ cause a segfault on del

2021-01-15 Thread Xinmeng Xia
Xinmeng Xia added the comment: Thank you. But I am not sure this is a recursion problem. Please see the following example, I replace "__sizeof__" with "__class__". No segmentation fault. Everything goes well. mystr = "hello123" print(dir(mystr)) for x in range(1

[issue42887] 100000 assignments of .__sizeof__ cause a segfault on del

2021-01-15 Thread Terry J. Reedy
Terry J. Reedy added the comment: Xinmeng, to verify Ronald's explanation, run this instead mystr = "hello123" for x in range(100): mystr = mystr.__sizeof__() input('>') # Hit Enter to continue. del mystr # Expect crash here. input('<') # And never get here. -- nosy: +ter