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

Core interpreter should be linked with libgcc_s.so on Linux #81576

Closed
zwol mannequin opened this issue Jun 25, 2019 · 2 comments
Closed

Core interpreter should be linked with libgcc_s.so on Linux #81576

zwol mannequin opened this issue Jun 25, 2019 · 2 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@zwol
Copy link
Mannequin

zwol mannequin commented Jun 25, 2019

BPO 37395
Nosy @vstinner
Superseder
  • bpo-44434: _thread module: Remove redundant PyThread_exit_thread() call to avoid glibc fatal error: libgcc_s.so.1 must be installed for pthread_cancel to work
  • 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 2021-06-28.23:47:01.929>
    created_at = <Date 2019-06-25.01:09:57.428>
    labels = ['interpreter-core', 'type-crash']
    title = 'Core interpreter should be linked with libgcc_s.so on Linux'
    updated_at = <Date 2021-06-28.23:47:01.928>
    user = 'https://bugs.python.org/zwol'

    bugs.python.org fields:

    activity = <Date 2021-06-28.23:47:01.928>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-06-28.23:47:01.929>
    closer = 'vstinner'
    components = ['Interpreter Core']
    creation = <Date 2019-06-25.01:09:57.428>
    creator = 'zwol'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37395
    keywords = []
    message_count = 2.0
    messages = ['346468', '396677']
    nosy_count = 2.0
    nosy_names = ['vstinner', 'zwol']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '44434'
    type = 'crash'
    url = 'https://bugs.python.org/issue37395'
    versions = []

    @zwol
    Copy link
    Mannequin Author

    zwol mannequin commented Jun 25, 2019

    There are several existing issues (e.g. bpo-18748 and bpo-35866) where at least part of the problem is that GNU libc tried to dlopen() libgcc_s.so at a moment when that's not safe, e.g. during thread or process shutdown. This converts a recoverable error into a deadlock or crash.

    This is arguably a bug in glibc, but Python can easily work around it by linking the core interpreter (the python executable and/or libpython.so) with libgcc_s at build time (-lgcc_s) on Linux. It will then be loaded already if and when it's needed, and glibc won't try to load it on demand.

    In order for this to be 100% reliable, it needs to be at least theoretically possible for code within the interpreter to call a function defined in libgcc_s.so. _Unwind_Backtrace is probably the most practical option. (See https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/baselib--unwind-backtrace.html .)

    @zwol zwol mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump labels Jun 25, 2019
    @vstinner
    Copy link
    Member

    This is arguably a bug in glibc, but Python can easily work around it by linking the core interpreter (the python executable and/or libpython.so) with libgcc_s at build time (-lgcc_s) on Linux. It will then be loaded already if and when it's needed, and glibc won't try to load it on demand.

    I fixed the issue differently in bpo-44434.

    I mark this issue as a duplicate of bpo-44434.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant