Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting state of an exception object with a dic crashes Python 3.8.14 #97591

Open
xiaxinmeng opened this issue Sep 27, 2022 · 1 comment
Open
Labels
interpreter-core Interpreter core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@xiaxinmeng
Copy link

xiaxinmeng commented Sep 27, 2022

Crash report

The following programs defined a class C. In C, we perform dic clear() operation. When we set state of exception object with the dic, it causes segmentation fault on main branch (68c46ae) and latest stable Python 3.8.14. But it does not trigger any crashing on Python-3.11.0rc2 and Python 3.9.0.

class C(str):
    def __hash__(self):
        d.clear()
        return 0

d = {}
d[C()] = C()

e = Exception()
e.__setstate__(d)

Error messages

Segmentation Fault (Core dumped)

Your environment

  • CPython versions tested on: Python 3.8.14 and main branch (68c46ae)
  • Operating system and architecture: [GCC 7.5.0] on linux
@xiaxinmeng xiaxinmeng added the type-crash A hard crash of the interpreter, possibly with a core dump label Sep 27, 2022
@ronaldoussoren ronaldoussoren added the interpreter-core Interpreter core (Objects, Python, Grammar, and Parser dirs) label Sep 27, 2022
@gvanrossum
Copy link
Member

gvanrossum commented Sep 27, 2022

I ran this in main under the debugger and it looks like the crash actually occurs during final cleanup, in ClearWeakRefs called from free_keys_object. Not sure if I have the guts to continue debugging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core Interpreter core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

3 participants