This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: test_crypt segfaults when using libxcrypt instead of libcrypt
Type: Stage: resolved
Components: Extension Modules Versions: Python 3.7, Python 3.6, Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Arfrever, benjamin.peterson, christian.heimes, cstratak, geofft, vstinner
Priority: normal Keywords: patch

Created on 2018-01-23 10:22 by cstratak, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit
00290-cryptmodule-Include-crypt.h-for-declaration-of-crypt.patch cstratak, 2018-01-23 10:22 review
Pull Requests
URL Status Linked Edit
PR 5284 merged cstratak, 2018-01-23 12:15
PR 5295 merged python-dev, 2018-01-24 09:36
PR 5296 merged python-dev, 2018-01-24 09:36
Messages (10)
msg310490 - (view) Author: Charalampos Stratakis (cstratak) * Date: 2018-01-23 10:22
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.

msg310503 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-01-23 15:11
New changeset e768c86ef442ef89004089a8a34ce5909ffb90f2 by Victor Stinner (stratakis) in branch 'master':
 bpo-32635: Fix a segfault when importing the crypt module with libxcrypt. (#5284)
msg310563 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2018-01-24 05:41
Incidentally, why did this manifest as a segfault rather than a compilation error?
msg310573 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-01-24 09:42
Charalampos, Christian: are you ok to backport the fix to Python 2.7 and 3.6? (PR 5295 and PR 5296)
msg310575 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2018-01-24 09:42
yes, go ahead
msg310579 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-01-24 09:51
New changeset 6ccdad7b1f6fb316e4e85aa1eba8fbdc3169741e by Victor Stinner (Miss Islington (bot)) in branch '2.7':
bpo-32635: Fix a segfault when importing the crypt module with libxcrypt. (GH-5284) (#5295)
msg310581 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-01-24 10:11
New changeset 8e230e1eb3d38ad557b5dc5c31166afa35c01ff3 by Victor Stinner (Miss Islington (bot)) in branch '3.6':
bpo-32635: Fix a segfault when importing the crypt module with libxcrypt. (GH-5284) (#5296)
msg397959 - (view) Author: Geoffrey Thomas (geofft) * Date: 2021-07-21 19:14
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.
msg398254 - (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) Date: 2021-07-26 19:38
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*'.
msg398322 - (view) Author: Geoffrey Thomas (geofft) * Date: 2021-07-27 21:33
Opened #44751 and .
Date User Action Args
2022-04-11 14:58:56adminsetgithub: 76816
2021-07-27 21:33:23geofftsetmessages: + msg398322
2021-07-26 19:38:23Arfreversetnosy: + Arfrever
messages: + msg398254
2021-07-21 19:14:19geofftsetnosy: + geofft
messages: + msg397959
2018-01-24 13:30:26cstrataksetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-01-24 10:11:19vstinnersetmessages: + msg310581
2018-01-24 09:51:41vstinnersetmessages: + msg310579
2018-01-24 09:42:58christian.heimessetmessages: + msg310575
2018-01-24 09:42:00vstinnersetnosy: + christian.heimes
messages: + msg310573
2018-01-24 09:36:57python-devsetpull_requests: + pull_request5143
2018-01-24 09:36:02python-devsetpull_requests: + pull_request5142
2018-01-24 09:35:33vstinnersetversions: + Python 2.7, - Python 3.8
2018-01-24 05:41:18benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg310563
2018-01-23 15:11:26vstinnersetmessages: + msg310503
2018-01-23 12:42:33vstinnersetnosy: + vstinner
2018-01-23 12:15:43cstrataksetstage: patch review
pull_requests: + pull_request5130
2018-01-23 10:28:39cstrataksetcomponents: + Extension Modules
2018-01-23 10:28:26cstrataksetversions: + Python 3.6, Python 3.7, Python 3.8
2018-01-23 10:22:06cstratakcreate