Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dlopen fail on android 4.3 #141

Closed
tshirtman opened this issue Jul 29, 2013 · 12 comments
Closed

dlopen fail on android 4.3 #141

tshirtman opened this issue Jul 29, 2013 · 12 comments

Comments

@tshirtman
Copy link
Member

when my import import sleekxmpp in my service, i get a dlopen error

I/python  ( 3368):   File "/home/gaby/lcs/kitch/.buildozer/android/app/_applibs/sleekxmpp/__init__.py", line 9, in <module>
I/python  ( 3368):   File "/home/gaby/lcs/kitch/.buildozer/android/app/_applibs/sleekxmpp/basexmpp.py", line 22, in <module>
I/python  ( 3368):   File "/home/gaby/lcs/kitch/.buildozer/android/app/_applibs/sleekxmpp/roster/__init__.py", line 9, in <module>
I/python  ( 3368):   File "/home/gaby/lcs/kitch/.buildozer/android/app/_applibs/sleekxmpp/xmlstream/__init__.py", line 9, in <module>
I/python  ( 3368):   File "/home/gaby/lcs/kitch/.buildozer/android/app/_applibs/sleekxmpp/jid.py", line 18, in <module>
I/python  ( 3368):   File "/home/gaby/lcs/kitch/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/stringprep.py", line 8, in <module>
I/python  ( 3368): ImportError: dlopen failed: invalid flags to dlopen: 102

this was working just last week, and there was no major change in my code, so i though it could come from my android upgrade to 4.3… and bingo, there is indeed a change about this:
http://www.funkyandroid.com/aosp-JDQ39-JWR66V.html
"e66190d : Check for unknown flags passed to dlopen(3)."

@tito
Copy link
Member

tito commented Jul 29, 2013

fuck :(

@tshirtman
Copy link
Member Author

yeah, i've been trying to look into it, but it's very hard to find which call causes this, i was thinking about building a debug distro to use with gdb-remote, but not much time today for this.

@tito
Copy link
Member

tito commented Jul 29, 2013

Means... any current modules loaded with dlopen failed right now? That's a big issue. So not the one with libpymodules i guess, but the one outside it? Do you have a full log (from the first install / decompression?)

@tshirtman
Copy link
Member Author

what's weird is that only my service crash, my interface works perfectly, so i think it's not all dlopen. I'll post a more complete log.

@brousch
Copy link
Contributor

brousch commented Jul 29, 2013

Is this a problem only when compiling with with API 18, or for people
running Android 4.3?

On Mon, Jul 29, 2013 at 8:19 AM, Mathieu Virbel [email protected]:

Means... any current modules loaded with dlopen failed right now? That's a
big issue. So not the one with libpymodules i guess, but the one
outside it? Do you have a full log (from the first install / decompression?)


Reply to this email directly or view it on GitHubhttps://github.com//issues/141#issuecomment-21715930
.

Ben Rousch
[email protected]
http://clusterbleep.net/

@tito
Copy link
Member

tito commented Jul 29, 2013

I guess people who run android 4.3.

@tito
Copy link
Member

tito commented Jul 29, 2013

My current analysis is: stringprep.py line 8 refers to from unicodedata import ucd_3_2_0 as unicodedata. unicodedata.so is imported via _PyImport_GetDynLoadFunc. So it will rely on the call:

handle = dlopen(pathname, dlopenflags);

The dlopenflags is initialized to 0, and set to:

dlopenflags = PyThreadState_GET()->interp->dlopenflags;

Which is set by default to:

build/hostpython/Python-2.7.2/Python/pystate.c:80:        interp->dlopenflags = RTLD_NOW;
build/hostpython/Python-2.7.2/Python/pystate.c:82:        interp->dlopenflags = RTLD_LAZY;

OR, set manually by sys.setdlopenflags().

The flags accepted by Android 4.3 are checked from this commit: https://android.googlesource.com/platform/bionic/+/e66190d%5E%21/#F1 | relevant part:

+  if ((flags & ~(RTLD_NOW|RTLD_LAZY|RTLD_LOCAL|RTLD_GLOBAL)) != 0) {
+    DL_ERR("invalid flags to dlopen: %x", flags);
+    return NULL;
+  }

Somewhere, somebody changed the flags, and set a wrong value?

@tshirtman
Copy link
Member Author

my full log from uninstall/reinstall to crash
http://paste.ubuntu.com/5925088/

and yeah, i found about as much, though was not sure who loaded the .so (__PyImport_GetDynLoadFunc ok), maybe the values of the declarations changed, because the constants seems to be the same.

@tito
Copy link
Member

tito commented Jul 29, 2013

I really hope it's not that... because it would be ÜBER SILLY

@tito
Copy link
Member

tito commented Jul 29, 2013

On linux:

#define RTLD_LAZY   0x00001 /* Lazy function call binding.  */
#define RTLD_NOW    0x00002 /* Immediate function call binding.  */
#define RTLD_BINDING_MASK   0x3 /* Mask of binding time value.  */
#define RTLD_NOLOAD 0x00004 /* Do not load the object.  */
#define RTLD_DEEPBIND   0x00008 /* Use deep binding.  */
#define RTLD_GLOBAL 0x00100
#define RTLD_LOCAL  0
#define RTLD_NODELETE   0x01000

On android:

enum {
  RTLD_NOW  = 0,
  RTLD_LAZY = 1,
  RTLD_LOCAL  = 0,
  RTLD_GLOBAL = 2,
};

Still, during compilation, the flags should be set to the right value.....

@tito
Copy link
Member

tito commented Jul 29, 2013

invalid flags to dlopen: 102 -> the value is hex, so for the linux way, it should mean:RTLD_GLOBAL | RTLD_NOW.

Values are set manually somewhere.

@tito
Copy link
Member

tito commented Jul 29, 2013

e9875e4 - fixed.

@tito tito closed this as completed Jul 29, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants