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

Created on 2014-04-30 07:33 by lizhenhua.dev, last changed 2014-04-30 09:56 by matrixise.

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 (3)
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 triager) Date: 2014-04-30 09:56
+1 for the patch
History
Date User Action Args
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