GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `mmap.mmap.__setitem__` crashes when concurrently resized · Issue #157335 · python/cpython

mmap.mmap.__setitem__ crashes when concurrently resized #157335

New issue
Copy link
New issue
Copy link
Closed
#157438
Closed
mmap.mmap.__setitem__ crashes when concurrently resized#157335
#157438
Copy link
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@djarfluka
djarfluka
opened on Sep 11, 2026
Issue body actions

Bug report

Bug description:

import mmap
mm = mmap.mmap(-1, 100000)         
class mid:
    def __index__(self):
        mm.resize(8)           
        return 0
mm[90000] = mid()          

AddressSanitizer:DEADLYSIGNAL

==1==ERROR: AddressSanitizer: SEGV on unknown address 0xffffa1a0cf90 (pc 0xffffa1a2aff0 bp 0xffffd2152970 sp 0xffffd2152830 T0)
==1==The signal is caused by a WRITE memory access.
#0 0xffffa1a2aff0 in safe_byte_copy Modules/mmapmodule.c:406
#1 0xffffa1a2aff0 in mmap_ass_subscript_lock_held Modules/mmapmodule.c:1692
#2 0xffffa1a2aff0 in mmap_ass_subscript Modules/mmapmodule.c:1750
#3 0xaaaadf0a9860 in _PyEval_EvalFrameDefault Python/generated_cases.c.h:12634
#4 0xaaaadf970b1c in _PyEval_EvalFrame Include/internal/pycore_ceval.h:122
#5 0xaaaadf970b1c in _PyEval_Vector Python/ceval.c:2174
#6 0xaaaadf970b1c in PyEval_EvalCode Python/ceval.c:679
#7 0xaaaadfb6feb4 in run_mod Python/pythonrun.c:1509
#8 0xaaaadfb70d38 in _PyRun_File Python/pythonrun.c:1332
#9 0xaaaadfb74ffc in _PyRun_SimpleFile Python/pythonrun.c:544
#10 0xaaaadfb78dd0 in _PyRun_AnyFile Python/pythonrun.c:92
#11 0xaaaadfc4390c in pymain_run_file_obj Modules/main.c:478
#12 0xaaaadfc4390c in pymain_run_file Modules/main.c:494
#13 0xaaaadfc4390c in pymain_run_python Modules/main.c:804
#14 0xaaaadfc4390c in Py_RunMain Modules/main.c:891
#15 0xaaaadfc45c38 in pymain_main Modules/main.c:921
#16 0xaaaadfc45c38 in Py_BytesMain Modules/main.c:945
#17 0xffffa46f84c0 (/lib/aarch64-linux-gnu/libc.so.6+0x284c0) (BuildId: 27027b96e5b8c475fc327aa445bea1c71d37b4e2)
#18 0xffffa46f8594 in __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x28594) (BuildId: 27027b96e5b8c475fc327aa445bea1c71d37b4e2)
#19 0xaaaadf0ebeec in _start (/src/cpython/python+0x183beec) (BuildId: eba909a3db0adabacf151d7dc3081dda7999191a)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV Modules/mmapmodule.c:406 in safe_byte_copy
==1==ABORTING

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

  • gh-157335: Fix out-of-bounds write in mmap.mmap.__setitem__ #157438
  • [3.15] gh-157335: Fix out-of-bounds write in mmap.mmap.__setitem__ (GH-157438) #158026
  • [3.14] gh-157335: Fix out-of-bounds write in mmap.mmap.__setitem__ (GH-157438) #158027
  • [3.13] gh-157335: Fix out-of-bounds write in mmap.mmap.__setitem__ (#157438) #158028

Activity

  1. djarfluka
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Sep 11, 2026
  2. picnixz commented on Sep 11, 2026

    @picnixz
    picnixz
    on Sep 11, 2026
    Member
    More actions

    I don't remember whether this was considered legitimate or not (that is, messing up with mmap like that).
    I feel that this is close to #148650 (maybe not the same cause, but similar issue, that is concurrent mutation).

    cc @serhiy-storchaka @vstinner

  3. picnixz
    added
    extension-modulesC modules in the Modules dirC modules in the Modules dir
    on Sep 11, 2026
  4. picnixz
    changed the title [-]mmap segfault[/-] [+]`mmap.mmap.__setitem__` crashes when concurrently resized[/+] on Sep 11, 2026
  5. picnixz commented on Sep 11, 2026

    @picnixz
    picnixz
    on Sep 11, 2026
    Member
    More actions

    @djarfluka Btw, is it a core dump when built without ASAN or is it a silent out-of-bound write?

  6. djarfluka commented on Sep 11, 2026

    @djarfluka
    djarfluka
    on Sep 11, 2026
    Author
    More actions

    @picnixz sorry for the messy bug report. will give more descriptive titles in the future. I'm seeing a silent oob write

    Reacted by Bénédikt Tran
  7. Joekrry
    added 2 commits that reference this issue on Sep 15, 2026

    pythongh-157335: Address review feedback on mmap setitem reentrancy fix

    4095226

    pythongh-157335 Removed redundant CHECK_VALID check.

    11cbbe9
  8. vstinner
    closed this as completedin #157438on Sep 23, 2026
  9. vstinner
    added a commit that references this issue on Sep 23, 2026

    gh-157335: Fix out-of-bounds write in mmap.mmap.__setitem__ (#157438)

    09bf4c5
  10. vstinner commented on Sep 23, 2026

    @vstinner
    vstinner
    on Sep 23, 2026
    Member
    More actions

    The reproducer now fails with:

    Traceback (most recent call last):
      File "script.py", line 7, in <module>
        mm[90000] = mid()
        ~~^^^^^^^
    IndexError: mmap index out of range
    
  11. vstinner
    added 2 commits that reference this issue on Sep 23, 2026

    [3.13] gh-157335: Fix out-of-bounds write in mmap.mmap.__setitem__ (#…

    edabbff

    [3.14] gh-157335: Fix out-of-bounds write in mmap.mmap.__setitem__ (G…

    c554143
  12. hugovk
    added a commit that references this issue on Sep 28, 2026

    [3.15] gh-157335: Fix out-of-bounds write in mmap.mmap.__setitem__ (G…

    960f69c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.