homepage

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: gethostbyname_r() is broken on android
Type: behavior Stage: resolved
Components: Cross-Build Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: skrah Nosy List: Alex.Willmer, python-dev, skrah, xdegaye, yan12125
Priority: normal Keywords: patch

Created on 2016年04月26日 13:33 by xdegaye, last changed 2022年04月11日 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
socketmodule.patch xdegaye, 2016年04月26日 13:33 review
socketmodule_2.patch xdegaye, 2016年05月11日 06:44 conditional on __ANDROID_API__ value review
issue26857.diff skrah, 2016年05月22日 13:36 review
Messages (13)
msg264280 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2016年04月26日 13:33
HAVE_GETHOSTBYNAME_R is defined on android API 21, but importing the _socket module fails with:
 ImportError: dlopen failed: cannot locate symbol "gethostbyaddr_r" referenced by "_socket.cpython-36m-i386-linux-gnu.so"
Patch attached.
The patch does not take into account the fact that this may be fixed in future versions of android.
msg264290 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016年04月26日 14:20
New changeset eb19ad1918cd by Stefan Krah in branch 'default':
Issue #26857: Workaround for missing symbol "gethostbyaddr_r" on Android.
https://hg.python.org/cpython/rev/eb19ad1918cd 
msg264296 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2016年04月26日 14:37
Thanks, fixed.
msg265292 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2016年05月11日 06:44
gethostbyaddr_r() is implemented now on Android 6.0 (API 23). The attached patch has been tested on the android-21-x86 emulator (API 21) and android-23-x86 emulator (API 23). No new NDK has been released at Android 5.1 (API 22) so there is no need to test the patch for this release.
msg265309 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2016年05月11日 12:17
How about supporting API >= 23 only? Can people upgrade their devices or do they have to buy a new one?
msg265310 - (view) Author: (yan12125) * Date: 2016年05月11日 12:48
> Can people upgrade their devices or do they have to buy a new one?
AFAIK most models other than Nexus won't get updates with a bumped major version. (5.x => 6.x for example)
msg265315 - (view) Author: (yan12125) * Date: 2016年05月11日 13:28
By the way, socketmodule_2.patch is problematic. Developers may choose to build CPython against API level 21 and run it on all devices with API level >= 21. In general Android keeps ABI compatibility between consecutive versions. That is, most binaries built for API 21 can be run on API 21, 22, 23 and 24. With this patch, developers have to build two versions of CPython, one for API < 23 and one for API >= 23, or gethostbyname_r() may not be used.
msg265321 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2016年05月11日 15:42
So what is problematic with this new patch ? Obviously you need to build with API 23 to get gethostbyname_r() since it was not supported by android before, with the previous patch you don't get gethostbyname_r(), even when building with API 23.
msg265323 - (view) Author: (yan12125) * Date: 2016年05月11日 15:54
I was thinking the (somewhat hacky) dlopen() approach so that gethostbyname_r() works in API 21 builds. If a universal build is not necessary this patch is OK.
msg266077 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2016年05月22日 13:36
Okay thanks, let's assume api-level >= 21 for now. I've moved the include into pyport.h in order to save a little space everywhere. Could you check if that works?
msg266079 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2016年05月22日 14:50
> I've moved the include into pyport.h
and also fixed the error in my patch, thanks :)
With issue26857.diff, importing the socket module does not fail both with an API 21 emulator and an API 23 emulator.
msg266082 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016年05月22日 15:36
New changeset 09af54099973 by Stefan Krah in branch 'default':
Issue #26857: The gethostbyaddr_r() workaround is no longer needed with
https://hg.python.org/cpython/rev/09af54099973 
msg266083 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2016年05月22日 15:37
Thanks! Closing again.
History
Date User Action Args
2022年04月11日 14:58:30adminsetgithub: 71044
2016年05月22日 15:37:26skrahsetstatus: open -> closed
resolution: fixed
messages: + msg266083
2016年05月22日 15:36:16python-devsetmessages: + msg266082
2016年05月22日 14:50:26xdegayesetmessages: + msg266079
2016年05月22日 13:36:23skrahsetfiles: + issue26857.diff

messages: + msg266077
2016年05月11日 15:54:52yan12125setmessages: + msg265323
2016年05月11日 15:42:37xdegayesetmessages: + msg265321
2016年05月11日 13:28:06yan12125setmessages: + msg265315
2016年05月11日 12:48:14yan12125setmessages: + msg265310
2016年05月11日 12:17:38skrahsetnosy: + yan12125
messages: + msg265309
2016年05月11日 06:44:07xdegayesetstatus: closed -> open
files: + socketmodule_2.patch
resolution: fixed -> (no value)
messages: + msg265292
2016年04月26日 16:04:41zach.warelinkissue26865 dependencies
2016年04月26日 14:37:00skrahsetstatus: open -> closed

assignee: skrah

nosy: + skrah
messages: + msg264296
resolution: fixed
stage: resolved
2016年04月26日 14:20:52python-devsetnosy: + python-dev
messages: + msg264290
2016年04月26日 13:33:19xdegayecreate

AltStyle によって変換されたページ (->オリジナル) /