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

bisect.insort crashes the interpreter if key is a string #92839

Closed
PaulWGraham opened this issue May 16, 2022 · 3 comments
Closed

bisect.insort crashes the interpreter if key is a string #92839

PaulWGraham opened this issue May 16, 2022 · 3 comments
Assignees
Labels
type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@PaulWGraham
Copy link

Crash report

The following code will crash the interactive interpreter.

import bisect

x = []
y = {'a': 2 , "b" : 1 }
bisect.insort(x, y, key='b')

Error messages

None. Just dumped back to the command line from the interactive interpreter.

Your environment

  • CPython versions tested on:
    Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32

  • Operating system and architecture:
    Edition Windows 10 Pro
    Version 21H2
    Installed on ‎7/‎28/‎2021
    OS build 19044.1706
    Experience Windows Feature Experience Pack 120.2212.4170.0

@PaulWGraham PaulWGraham added the type-crash A hard crash of the interpreter, possibly with a core dump label May 16, 2022
@stevendaprano
Copy link
Member

Verified that there is a segmentation fault on Linux too, using Python 3.10.0.

@ghost
Copy link

ghost commented May 16, 2022

There appears to be a typo in the implementation: _bisectmodule.c (line number 131). I think that instead of if (x == NULL), if (key_x == NULL) was intended. This fixes it for me.

@rhettinger
Copy link
Contributor

Confirmed.

miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 28, 2022
)

(cherry picked from commit 7fa9b7d)

Co-authored-by: oda-gitso <105083118+oda-gitso@users.noreply.github.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 28, 2022
)

(cherry picked from commit 7fa9b7d)

Co-authored-by: oda-gitso <105083118+oda-gitso@users.noreply.github.com>
miss-islington added a commit that referenced this issue May 28, 2022
(cherry picked from commit 7fa9b7d)

Co-authored-by: oda-gitso <105083118+oda-gitso@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

3 participants