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.

classification
Title: readline: setlocale() returns NULL on Android
Type: Stage: resolved
Components: Cross-Build Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: iritkatriel, lizhenhua.dev, matrixise, vstinner
Priority: normal Keywords: patch

Created on 2014-04-30 07:33 by lizhenhua.dev, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
strdup.patch lizhenhua.dev, 2014-04-30 07:33 review
readline_android.patch vstinner, 2014-04-30 09:52 review
Messages (5)
msg217580 - (view) Author: Li Zhenhua (lizhenhua.dev) * Date: 2014-04-30 07:33
On Android platform, when run "python" command without any scripts, it may crash, get an error message "Segment Fault". This is because strdup with a NULL pointer. 

Details:
In file 
    Modules/readline.c, 
function
    static void setup_readline(void)

This line:
    char *saved_locale = strdup(setlocale(LC_CTYPE, NULL));

When running on an Android platform, setlocale(LC_CTYPE, NULL) returns NULL, and this causes strdup with a NULL pointer, then Segment Fault occurs.
msg217589 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-04-30 09:52
Here is a patch.
msg217590 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2014-04-30 09:56
+1 for the patch
msg408462 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-12-13 16:34
Neither of the patches were applied. Is this still needed?
msg408471 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-12-13 17:29
Since 2014, Android got getter support for Unix locales.

Since nobody was able to say if the issue still exists on Android since 2014, nor if my patch fix the issue, I perfer to close the issue as out of date.
History
Date User Action Args
2022-04-11 14:58:03adminsetgithub: 65589
2021-12-13 17:29:09vstinnersetstatus: open -> closed
resolution: out of date
messages: + msg408471

stage: resolved
2021-12-13 16:34:00iritkatrielsetnosy: + iritkatriel
messages: + msg408462
2014-04-30 09:56:09matrixisesetnosy: + matrixise
messages: + msg217590
2014-04-30 09:52:45vstinnersetfiles: + readline_android.patch
title: strdup may cause Segment Fault on Android -> readline: setlocale() returns NULL on Android
nosy: + vstinner

messages: + msg217589

versions: + Python 2.7, Python 3.4
2014-04-30 07:33:43lizhenhua.devcreate