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

dlsym crashes in Android API < 21 #820

Closed
kokje opened this issue Feb 16, 2018 · 8 comments
Closed

dlsym crashes in Android API < 21 #820

kokje opened this issue Feb 16, 2018 · 8 comments
Labels
android Related to the Android OS.
Milestone

Comments

@kokje
Copy link

kokje commented Feb 16, 2018

Hi,

A bug in kernel VDSO lookup causes dlsym to crash with SIGFPE
https://github.com/carllerche/mio/blob/db2a5e8ac136791a1c7b66a7d118ac4876c9c119/src/sys/unix/dlsym.rs#L43
https://android-review.googlesource.com/c/platform/bionic/+/69033

epoll_create1 was not implemented in bionic until API 21
https://android.googlesource.com/platform/bionic/+/master/libc/libc.map.txt#308

A possible workaround could be to use syscall directly?

@carllerche
Copy link
Member

Well, the issue is that epoll_create1 is superior due to EPOLL_CLOEXEC. So it is best to use it when possible.

Do you have thoughts on how to conditionally use epoll_create1 without a dlsym check?

@kokje
Copy link
Author

kokje commented Feb 16, 2018

I think making a direct syscall is a good option. On failure it should return a -1 with the associate errno value
ex: syscall(__NR_epoll_create1, EPOLL_CLOEXEC)
using https://github.com/rust-lang/libc/blob/bbda50d20937e570df5ec857eea0e2a098e76b2d/src/unix/notbsd/android/mod.rs#L1066

There are a couple of other ways discussed here: android/ndk#302

@maltzj
Copy link

maltzj commented Feb 28, 2018

Poking this as a concerned Android dev. What are your feelings on using a syscall?

@carllerche
Copy link
Member

@maltzj If this is the accepted strategy for android, it should be fine.

@hawkw hawkw added the android Related to the Android OS. label Aug 16, 2018
@Thomasdezeeuw
Copy link
Collaborator

Android API level < 21 has less then 10% according to https://developer.android.com/about/dashboards, do we still want to support it?

If so, this is the solution by libuv: https://github.com/libuv/libuv/blob/d7f0055b8014196b3c3a3a4eaf86e6ea81745ff0/src/unix/linux-core.c#L89-L103.

@Thomasdezeeuw Thomasdezeeuw added this to the v0.7 milestone Jun 17, 2019
@carllerche
Copy link
Member

We are bumping the min linux kernel on master, so we can stop using dlsym I think?

@carllerche
Copy link
Member

I also think we could probably just copy what libuv does for initialization here.

@Thomasdezeeuw
Copy link
Collaborator

Pr #1005 switches to using epoll_create1 also removing dlsym, so I don't think this is an issue anymore. If still is still an issue on the master branch, feel free to reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Related to the Android OS.
Projects
None yet
Development

No branches or pull requests

5 participants