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

KeyboardInterrupt inside dict key's __str__ method leads to segmentation fault #522

Closed
JustAnotherArchivist opened this issue Apr 7, 2022 · 1 comment · Fixed by #526

Comments

@JustAnotherArchivist
Copy link
Collaborator

Reported by @smason in #419, filing as a separate issue so it doesn't get lost after that issue is fixed:

While debugging this I also noticed that if I hit Ctl+C in the above loop Python would sometimes get terminated with SIGSEGV . I can reliably reproduce this via:

class Obj:
    def __str__(self):
        raise KeyboardInterrupt

dumps({Obj(): 1})

I can still reproduce this with ujson 5.2.0, Python 3.10.1 on Debian Sid and also with #521 applied.

@JustAnotherArchivist
Copy link
Collaborator Author

There's an error check missing for PyObject_Str in Dict_iterNext. itemName becomes NULL when an exception is raised during the string conversion, and from there it blows up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant