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

[SR-5757] Android: SwiftRuntime dlopen() failed on `/system/lib/libcutils.so #48327

Closed
swift-ci opened this issue Aug 24, 2017 · 6 comments
Closed
Labels
Android Platform: Android bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-5757
Radar None
Original Reporter amraboelela (JIRA User)
Type Bug
Status Closed
Resolution Done
Environment

Android

Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug, Android
Assignee amraboelela (JIRA)
Priority Medium

md5: a52dc7b4e60f4e341cdcf24421b2bba6

Issue Description:

08-23 11:58:59.438 25922-25922/com.example.addswift A/SwiftRuntime: dlopen() failed on `/system/lib/libcutils.so': dlopen failed: library "/system/lib/libcutils.so" wasn't loaded and RTLD_NOLOAD prevented it

                  • beginning of crash
                    08-23 11:58:59.448 25922-25922/com.example.addswift A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 25922 (xample.addswift)

[ 08-23 11:58:59.451 645: 645 W/ ]
debuggerd: handling request: pid=25922 uid=10061 gid=10061 tid=25922
08-23 11:58:59.671 25957-25957/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
08-23 11:58:59.672 25957-25957/? A/DEBUG: Build fingerprint: 'Android/sdk_phone_armv7/generic:7.0/NYC/3245079:userdebug/test-keys'
08-23 11:58:59.672 25957-25957/? A/DEBUG: Revision: '0'
08-23 11:58:59.672 25957-25957/? A/DEBUG: ABI: 'arm'
08-23 11:58:59.673 25957-25957/? A/DEBUG: pid: 25922, tid: 25922, name: xample.addswift >>> com.example.addswift <<<
08-23 11:58:59.673 25957-25957/? A/DEBUG: signal 6 (SIGABRT), code 6 (SI_TKILL), fault addr -------
08-23 11:58:59.693 25957-25957/? A/DEBUG: Abort message: 'dlopen() failed on `/system/lib/libcutils.so': dlopen failed: library "/system/lib/libcutils.so" wasn't loaded and RTLD_NOLOAD prevented it'
08-23 11:58:59.694 25957-25957/? A/DEBUG: r0 00000000 r1 00006542 r2 00000006 r3 00000008
08-23 11:58:59.694 25957-25957/? A/DEBUG: r4 ad71c584 r5 00000006 r6 ad71c52c r7 0000010c
08-23 11:58:59.695 25957-25957/? A/DEBUG: r8 92565cb0 r9 bef4f2e8 sl 925f31ac fp bef4f218
08-23 11:58:59.695 25957-25957/? A/DEBUG: ip 00000058 sp bef4f1c0 lr ace2932f pc ace2bb7c cpsr 20000010
08-23 11:58:59.730 25957-25957/? A/DEBUG: backtrace:
08-23 11:58:59.730 25957-25957/? A/DEBUG: #00 pc 00048b7c /system/lib/libc.so (tgkill+12)
08-23 11:58:59.731 25957-25957/? A/DEBUG: #1 pc 0004632b /system/lib/libc.so (pthread_kill+34)
08-23 11:58:59.731 25957-25957/? A/DEBUG: #2 pc 0001c6d5 /system/lib/libc.so (raise+10)
08-23 11:58:59.731 25957-25957/? A/DEBUG: #3 pc 00018237 /system/lib/libc.so (__libc_android_abort+34)
08-23 11:58:59.732 25957-25957/? A/DEBUG: #4 pc 00017770 /system/lib/libc.so (abort+4)
08-23 11:58:59.732 25957-25957/? A/DEBUG: #5 pc 004de804 /data/app/com.example.addswift-2/lib/arm/libswiftCore.so

@swift-ci
Copy link
Collaborator Author

Comment by Amr Aboelela (JIRA)

@milseman can you help with this error?

@milseman
Copy link
Mannequin

milseman mannequin commented Aug 24, 2017

I'm afraid that is well beyond my understanding. Any idea why that is trying to be opened? Also does that .so exist at that path? RTLD_NOLOAD should attempt to determine if it's there, but I believe it won't try to actually do the load.

@swift-ci
Copy link
Collaborator Author

Comment by Amr Aboelela (JIRA)

I found in https://developer.android.com/about/versions/nougat/android-7.0-changes.html

In order to reduce the impact that this restriction may have on currently released apps, a set of libraries that see significant use—such as libandroid_runtime.so, libcutils.so, libcrypto.so, and libssl.so—are temporarily accessible on Android 7.0 (API level 24) for apps targeting API level 23 or lower. If your app loads one of these libraries, logcat generates a warning and a toast appears on the target device to notify you. If you see these warnings, you should update your app to either include its own copy of those libraries or only use the public NDK APIs. Future releases of the Android platform may restrict the use of private libraries altogether and cause your app to crash.

@milseman
Copy link
Mannequin

milseman mannequin commented Aug 24, 2017

I'm not sure what you're looking for here. I'm completely unfamiliar with Android and am not in a position where I can even test potential approaches. If you have questions about the standard library or generic Darwin/Linux functionality, I might be able to advise.

@swift-ci
Copy link
Collaborator Author

Comment by Amr Aboelela (JIRA)

Created PR #11615

@swift-ci
Copy link
Collaborator Author

Comment by Amr Aboelela (JIRA)

It turned out that this error is coming from this function in ImageInspectionELF.cpp from the line marked red.

static SectionInfo getSectionInfo(const char *imageName,

                              const char \*sectionName) {

SectionInfo sectionInfo = { 0, nullptr };

void *handle = dlopen(imageName, RTLD_LAZY | RTLD_NOLOAD);

if (!handle) {

 <span color="#ff0000">fatalError(/\* flags = \*/ 0, "dlopen() failed on \`%s': %s", imageName, dlerror());</span>

}

...

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Platform: Android bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

1 participant