Skip to content

test_crypt segfaults when using libxcrypt instead of libcrypt #76816

Closed

Description

@stratakis
mannequin
BPO 32635
Nosy @vstinner, @tiran, @benjaminp, @stratakis, @geofft
PRs
  • bpo-32635: Fix a segfault when importing the crypt module with libxcrypt. #5284
  • [2.7] bpo-32635: Fix a segfault when importing the crypt module with libxcrypt. (GH-5284) #5295
  • [3.6] bpo-32635: Fix a segfault when importing the crypt module with libxcrypt. (GH-5284) #5296
  • Files
  • 00290-cryptmodule-Include-crypt.h-for-declaration-of-crypt.patch
  • 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 2018-01-24.13:30:26.894>
    created_at = <Date 2018-01-23.10:22:06.979>
    labels = ['extension-modules', '3.7']
    title = 'test_crypt segfaults when using libxcrypt instead of libcrypt'
    updated_at = <Date 2021-07-27.21:33:23.914>
    user = 'https://github.com/stratakis'

    bugs.python.org fields:

    activity = <Date 2021-07-27.21:33:23.914>
    actor = 'geofft'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-01-24.13:30:26.894>
    closer = 'cstratak'
    components = ['Extension Modules']
    creation = <Date 2018-01-23.10:22:06.979>
    creator = 'cstratak'
    dependencies = []
    files = ['47402']
    hgrepos = []
    issue_num = 32635
    keywords = ['patch']
    message_count = 10.0
    messages = ['310490', '310503', '310563', '310573', '310575', '310579', '310581', '397959', '398254', '398322']
    nosy_count = 6.0
    nosy_names = ['vstinner', 'christian.heimes', 'benjamin.peterson', 'Arfrever', 'cstratak', 'geofft']
    pr_nums = ['5284', '5295', '5296']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue32635'
    versions = ['Python 2.7', 'Python 3.6', 'Python 3.7']

    Activity

    1. stratakis commented on Jan 23, 2018

      stratakismannequin
      MannequinAuthor

      Currently in Fedora glibc stopped providing libcrypt[0] a change which is slowly being upstreamed as well[1] in favor of the libxcrypt project[2].

      This causes a segfault when importing the crypt module as python assumes that crypt.h is always available.

      Providing a working patch from the libxcrypt maintainer. I'll convert the patch into a PR.

      [0] https://fedoraproject.org/wiki/Changes/Replace_glibc_libcrypt_with_libxcrypt
      [1] https://sourceware.org/ml/libc-alpha/2017-08/msg01257.html
      [2] https://github.com/besser82/libxcrypt

    2. vstinner commented on Jan 23, 2018

      @vstinner
      Member

      New changeset e768c86 by Victor Stinner (stratakis) in branch 'master':
      bpo-32635: Fix a segfault when importing the crypt module with libxcrypt. (bpo-5284)
      e768c86

    3. benjaminp commented on Jan 24, 2018

      @benjaminp
      Contributor

      Incidentally, why did this manifest as a segfault rather than a compilation error?

    4. vstinner commented on Jan 24, 2018

      @vstinner
      Member

      Charalampos, Christian: are you ok to backport the fix to Python 2.7 and 3.6? (PR 5295 and PR 5296)

    5. tiran commented on Jan 24, 2018

      @tiran
      Member

      yes, go ahead

    6. vstinner commented on Jan 24, 2018

      @vstinner
      Member

      New changeset 6ccdad7 by Victor Stinner (Miss Islington (bot)) in branch '2.7':
      bpo-32635: Fix a segfault when importing the crypt module with libxcrypt. (GH-5284) (bpo-5295)
      6ccdad7

    7. vstinner commented on Jan 24, 2018

      @vstinner
      Member

      New changeset 8e230e1 by Victor Stinner (Miss Islington (bot)) in branch '3.6':
      bpo-32635: Fix a segfault when importing the crypt module with libxcrypt. (GH-5284) (bpo-5296)
      8e230e1

    8. geofft commented on Jul 21, 2021

      geofftmannequin
      Mannequin

      Sorry to bump an old thread, but - does <crypt.h> need to be in the public Python.h header? Or would it be enough to be in _cryptmodule.c, which is the code that uses crypt_r()?

      I can provide a quick patch to change that if that seems sound.

    9. Arfrever commented on Jul 26, 2021

      Arfrevermannequin
      Mannequin

      Geoffrey Thomas:
      I agree that including crypt.h only where required is better.
      Can you file new bug with patch?

      Benjamin Peterson:
      I suspect that with crypt.h not included in _cryptmodule.c, crypt() was treated by compiler as implicitly declared function (returning 'int'), however real crypt() function returns 'char*'.

    10. geofft commented on Jul 27, 2021

      geofftmannequin
      Mannequin

      Opened bpo-44751 and #27394 .

    11. transferred this issue fromon Apr 10, 2022
    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

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions