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

prebuild prefab package can't be used with ndk > 21.0.6113669 #966

Closed
brunotl opened this issue Aug 4, 2020 · 6 comments
Closed

prebuild prefab package can't be used with ndk > 21.0.6113669 #966

brunotl opened this issue Aug 4, 2020 · 6 comments
Assignees
Labels
bug P1 high priority

Comments

@brunotl
Copy link

brunotl commented Aug 4, 2020

due to ndk issues android/ndk#1166

tested with "hello-oboe" sample project : https://github.com/android/ndk-samples/tree/master/hello-oboe

2020-08-04 10:47:28.120 6570-6570/com.google.example.hellooboe E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.google.example.hellooboe, PID: 6570
    java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_Unwind_Resume" referenced by "/data/app/com.google.example.hellooboe-V_WR6gfOI4FnWmQn9ax7oA==/lib/arm64/liboboe.so"...
        at java.lang.Runtime.loadLibrary0(Runtime.java:1071)
        at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
        at java.lang.System.loadLibrary(System.java:1668)
        at com.google.example.hellooboe.MainActivity.<clinit>(MainActivity.kt:74)
@dturner
Copy link
Collaborator

dturner commented Aug 4, 2020

Thanks for filing this. I just tried reproducing with the latest version of the NDK (version 21.3.6528147) and did not experience this issue, so it looks like it's already been fixed.

@dturner dturner closed this as completed Aug 4, 2020
@brunotl
Copy link
Author

brunotl commented Aug 4, 2020

@dturner dturner reopened this Aug 4, 2020
@dturner
Copy link
Collaborator

dturner commented Aug 4, 2020

Thanks for the extra info. I will follow up with the NDK team.

@dturner
Copy link
Collaborator

dturner commented Aug 5, 2020

It seems that Oboe was built using a version of the NDK which contained a bug (thanks to Dan Albert for help with diagnosis):

Here's the readelf output from liboboe.so version 1.4.2:

$ readelf -sW liboboe.so| grep _Unwind
    55: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _Unwind_Resume
  2007: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _Unwind_Resume

The UND in the Ndx column means Undefined symbol.

Rebuilding with NDK r21d I get the following output:

$ /Users/donturner/Library/Android/sdk/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/bin/aarch64-linux-android-readelf -sW arm64-v8a/liboboe.so | grep _Unwind
  1480: 000000000002babc    60 FUNC    LOCAL  DEFAULT   11 _Unwind_SetSpColumn
  1481: 000000000002baf8    88 FUNC    LOCAL  DEFAULT   11 _Unwind_GetGR.localalias.0
  1490: 000000000002cfa4   192 FUNC    LOCAL  DEFAULT   11 _Unwind_RaiseException_Phase2
  1491: 000000000002d064   236 FUNC    LOCAL  DEFAULT   11 _Unwind_ForcedUnwind_Phase2
  1492: 000000000002d244     4 FUNC    LOCAL  DEFAULT   11 _Unwind_DebugHook
  1513: 000000000002dea0  1052 FUNC    LOCAL  DEFAULT   11 _Unwind_IteratePhdrCallback
  1531: 000000000002d6cc   208 FUNC    LOCAL  DEFAULT   11 _Unwind_Backtrace
  1532: 000000000002bce8     8 FUNC    LOCAL  DEFAULT   11 _Unwind_GetRegionStart
  1533: 000000000002baf8    88 FUNC    LOCAL  DEFAULT   11 _Unwind_GetGR
  1535: 000000000002d248   376 FUNC    LOCAL  DEFAULT   11 _Unwind_RaiseException
  1537: 000000000002bcd8     8 FUNC    LOCAL  DEFAULT   11 _Unwind_SetIP
  1538: 000000000002bce0     8 FUNC    LOCAL  DEFAULT   11 _Unwind_GetLanguageSpecificData
  1544: 000000000002bd20     8 FUNC    LOCAL  DEFAULT   11 _Unwind_GetTextRelBase
  1546: 000000000002d5b0   248 FUNC    LOCAL  DEFAULT   11 _Unwind_Resume_or_Rethrow
  1548: 000000000002bc5c     8 FUNC    LOCAL  DEFAULT   11 _Unwind_GetCFA
  1549: 000000000002d3c0   244 FUNC    LOCAL  DEFAULT   11 _Unwind_ForcedUnwind
  1551: 000000000002bcc4    20 FUNC    LOCAL  DEFAULT   11 _Unwind_GetIPInfo
  1557: 000000000002ee38   452 FUNC    LOCAL  DEFAULT   11 _Unwind_Find_FDE
  1564: 000000000002d4b4   252 FUNC    LOCAL  DEFAULT   11 _Unwind_Resume
  1566: 000000000002bcf0    40 FUNC    LOCAL  DEFAULT   11 _Unwind_FindEnclosingFunction
  1567: 000000000002bcbc     8 FUNC    LOCAL  DEFAULT   11 _Unwind_GetIP
  1569: 000000000002bc64    88 FUNC    LOCAL  DEFAULT   11 _Unwind_SetGR
  1575: 000000000002d6a8    36 FUNC    LOCAL  DEFAULT   11 _Unwind_DeleteException
  1576: 000000000002bd18     8 FUNC    LOCAL  DEFAULT   11 _Unwind_GetDataRelBase

Note the UND has been replaced with 11 indicating that the symbols are in section 11.

Why did this happen? (paraphrased from Dan)
The UND doesn't necessarily mean that a library is built incorrectly - it is normal for symbols that come from a shared lib. But the unwind stuff is static on Android, so should always be defined in every executable/shared lib.

The symbols were wrongly reexported from libc++ this bug, so if libc++ appears on the link command before libgcc the linker resolves the symbol from libc++ instead.

Oboe 1.4.2 was built against a version of the NDK which contained this bug. So when users attempt to link against Oboe using versions of the NDK which don't contain this bug (i.e. have a fixed libc++ that no longer reexports the symbol) it causes this error.

What now?
I will rebuild Oboe 1.4.2 and upload a new prefab package.

@dturner dturner self-assigned this Aug 5, 2020
@dturner dturner added bug P1 high priority labels Aug 5, 2020
@dturner
Copy link
Collaborator

dturner commented Aug 5, 2020

I have created a new release: 1.4.3 which should fix this issue. I am just waiting on approval from @philburk or @android-usb to publish to GMaven.

I have published an updated AAR in case you would like to test it out without waiting for the GMaven artifact.

@philburk
Copy link
Collaborator

philburk commented Aug 9, 2020

Don release the new version.

@philburk philburk closed this as completed Aug 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug P1 high priority
Projects
None yet
Development

No branches or pull requests

3 participants