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 — Segfault when closing BufferedWriter from a different thread · Issue #76157 · python/cpython

Segfault when closing BufferedWriter from a different thread #76157

New issue
Copy link
New issue
Copy link
Closed
Closed
Segfault when closing BufferedWriter from a different thread#76157
Copy link
Labels
3.7 (EOL)end of lifeend of lifeinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump

Description

benfogle
mannequin
opened on Nov 8, 2017
Issue body actions
BPO 31976
Nosy @pitrou, @benjaminp, @vadmium, @benfogle
PRs
  • bpo-31976: Fix race condition when flushing a file is slow. #4331
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2017-11-10.21:05:15.294>
    created_at = <Date 2017-11-08.04:27:27.470>
    labels = ['interpreter-core', '3.7', 'type-crash']
    title = 'Segfault when closing BufferedWriter from a different thread'
    updated_at = <Date 2017-11-10.21:05:15.294>
    user = 'https://github.com/benfogle'

    bugs.python.org fields:

    activity = <Date 2017-11-10.21:05:15.294>
    actor = 'pitrou'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-11-10.21:05:15.294>
    closer = 'pitrou'
    components = ['Interpreter Core']
    creation = <Date 2017-11-08.04:27:27.470>
    creator = 'benfogle'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 31976
    keywords = ['patch']
    message_count = 3.0
    messages = ['305803', '306048', '306049']
    nosy_count = 5.0
    nosy_names = ['pitrou', 'benjamin.peterson', 'stutzbach', 'martin.panter', 'benfogle']
    pr_nums = ['4331']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue31976'
    versions = ['Python 3.7']

    Activity

    1. benfogle commented on Nov 8, 2017

      @benfogle
      benfoglemannequin
      on Nov 8, 2017
      MannequinAuthor
      More actions

      To reproduce:

      import threading
      import io
      import time
      import _pyio
      
      class MyFileIO(io.FileIO):
          def flush(self):
              # Simulate a slow flush. Slow disk, etc.
              time.sleep(0.25)
              super().flush()
      
      raw = MyFileIO('test.dat', 'wb')
      #fp = _pyio.BufferedWriter(raw)
      fp = io.BufferedWriter(raw)
      t1 = threading.Thread(target=fp.close)
      t1.start()
      time.sleep(0.1) # Ensure t1 is sleeping in fp.close()/raw.flush()
      fp.write(b'test')
      t1.join()
      

      _pyio.BufferedWriter ignores the error completely rather than throwing a ValueError("write to closed file").

    2. benfogle
      added
      3.7 (EOL)end of lifeend of life
      interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
      type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
      on Nov 8, 2017
    3. pitrou commented on Nov 10, 2017

      @pitrou
      pitrou
      on Nov 10, 2017
      Member
      More actions

      New changeset 9703f09 by Antoine Pitrou (benfogle) in branch 'master':
      bpo-31976: Fix race condition when flushing a file is slow. (bpo-4331)
      9703f09

    4. pitrou commented on Nov 10, 2017

      @pitrou
      pitrou
      on Nov 10, 2017
      Member
      More actions

      Thank you for posting this Benjamin. As I said on the PR, I don't think I want to backport this to 3.6, as it is always delicate to reason about subclassing and threads.

    5. pitrou
      closed this as completedon Nov 10, 2017
    6. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    7. cmaloney
      added a commit that references this issue on May 14, 2026

      exp: Introduce Nibbler in _pyio.BufferedWriter

      ff824fb
    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

      3.7 (EOL)end of lifeend of lifeinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump

      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.