Skip to content

Python crashed when I using GitPython. #1600

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

Closed
ChenPi11 opened this issue Jun 18, 2023 · 1 comment
Closed

Python crashed when I using GitPython. #1600

ChenPi11 opened this issue Jun 18, 2023 · 1 comment

Comments

@ChenPi11
Copy link

Crash report

When I was using Git.RemoteProgress and triggered SIGINT (pressing ^C) while working in GitPython, Python reported a fatal error and returned SIGABRT.

Error messages

^CTraceback (most recent call last):
  File "/workspaces/cppp-reiconv/build-aux/./tools/m4_update.py", line 75, in <module>
    clone("automake")
  File "/workspaces/cppp-reiconv/build-aux/./tools/m4_update.py", line 73, in clone
    return git.Repo.clone_from(url, to_path, progress=ProgressPrinter())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/git/repo/base.py", line 1325, in clone_from
    return cls._clone(
           ^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/git/repo/base.py", line 1221, in _clone
    handle_process_output(
  File "/home/user/.local/lib/python3.11/site-packages/git/cmd.py", line 182, in handle_process_output
    t.join(timeout=kill_after_timeout)
  File "/usr/lib/python3.11/threading.py", line 1112, in join
    self._wait_for_tstate_lock()
  File "/usr/lib/python3.11/threading.py", line 1132, in _wait_for_tstate_lock
    if lock.acquire(block, timeout):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt
Fatal Python error: _enter_buffered_busy: could not acquire lock for <_io.BufferedReader name=4> at interpreter shutdown, possibly due to daemon threads
Python runtime state: finalizing (tstate=0x000055f624ec74f8)

Current thread 0x00007fb76fb3e280 (most recent call first):
  File "/home/user/.local/lib/python3.11/site-packages/git/cmd.py", line 531 in _terminate
  File "/home/user/.local/lib/python3.11/site-packages/git/cmd.py", line 567 in __del__
zsh: abort      ********.py

Your environment

  • Linux 5.10.43-2-windows-subsystem-for-android
  • x86_64 Debian GNU/Linux

Recurrence error

#!/usr/bin/env python3

# Copyright (C) 2023 The C++ Plus Project.
# This file is part of the build-aux Library.
#
# The build-aux Library is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# The build-aux Library is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with the build-aux Library; see the file COPYING.
# If not, see <https://www.gnu.org/licenses/>.

# Update m4 scripts and autoconf scripts

import os
import shutil
import logging
import sys
import git
import git.remote

cwd = os.getcwd()

def get_logger(name:str, level:int=logging.DEBUG):
    log = logging.getLogger(name)
    log.setLevel(level)
    
    stream_handler = logging.StreamHandler(sys.stderr)
    stream_handler.setLevel(level)
    log.addHandler(stream_handler)
    
    formatter = logging.Formatter("[%(levelname)s %(name)s %(asctime)s] %(message)s")
    stream_handler.setFormatter(formatter)
    
    return log

class ProgressPrinter(git.RemoteProgress):
    def update(self, op_code, cur_count, max_count=None, message=''):
        print(cur_count , max_count,message)

def clone(repository:str):
    log = get_logger("GIT")
    log.info(f"Cloning repository {repository} ...")
    
    url = f"git://git.savannah.gnu.org/{repository}.git"
    to_path = os.path.join(cwd, repository)
    if os.path.exists(to_path):
        shutil.rmtree(to_path)
    return git.Repo.clone_from(url, to_path, progress=ProgressPrinter())

clone("automake")

After running this code for a period of time, when ProgressPrinter.update starts running, ^ C is triggered, and sometimes this exception occurs.

@Byron
Copy link
Member

Byron commented Jun 18, 2023

What is the expected behaviour? When asking the program to shut-down this still is happening, even though the exception might have some variation depending on what a background thread happens to do. Thus I don't think this has any chance of being fixed, and recommend closing.

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

No branches or pull requests

2 participants