Skip to content

[BUG] ndk-stack failing with UnicodeDecodeError due to NativeTombstoneManager #1993

Closed
@cortinico

Description

@cortinico

Description

Hey all,
I'm having problem running ndk-stack since upgrading to NDK 25.1 and 26.1

Specifically I'm invoking it with either stdin by piping adb logcat or passing a -dump, but the tool fails to work in both cases. The tool works correctly with NDK 23.1.

It seems like ndk-stack fails to read the input due to non UTF-8 chars in the log.
I'm uploading a dump taken from an Android emulator:
dump.txt

Specifically the non UTF-8 chars seems to be the following:

$ grep -axv '.*' dump.txt
01-08 15:14:19.624   559   638 E NativeTombstoneManager: Tombstone has invalid selinux label (u:r:priv_app:s0:c512,c768��), ignoring
01-15 16:25:12.557  3785  3861 E NativeTombstoneManager: Tombstone has invalid selinux label (u:r:priv_app:s0:c512,c768��), ignoring

It would be great if ndk-stack were to not fail on those characters, specifically also because NativeTombstoneManager is part of the Android SDK (and everything worked fine in NDK 23).

Stacktrace on NDK 26.1

$ adb logcat | $ANDROID_HOME/ndk/26.1.10909125/ndk-stack -sym packages/react-native/ReactAndroid/build/intermediates/cmake/debug/obj/arm64-v8a
Traceback (most recent call last):
  File "/opt/android_sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/python3/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/android_sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/python3/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/opt/android_sdk/ndk/26.1.10909125/prebuilt/darwin-x86_64/bin/ndkstack.pyz/__main__.py", line 3, in <module>
  File "/opt/android_sdk/ndk/26.1.10909125/prebuilt/darwin-x86_64/bin/ndkstack.pyz/ndkstack.py", line 387, in main
  File "/opt/android_sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/python3/lib/python3.10/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 7369: invalid start byte

Stacktrace on NDK 25.1

adb logcat | $ANDROID_HOME/ndk/25.1.8937393/ndk-stack -sym packages/react-native/ReactAndroid/build/intermediates/cmake/debug/obj/arm64-v8a
<_io.TextIOWrapper name='<stdin>' mode='r' encoding='utf-8'>
Traceback (most recent call last):
  File "/opt/android_sdk/ndk/25.1.8937393/prebuilt/darwin-x86_64/bin/ndk-stack.py", line 429, in <module>
    main(sys.argv[1:])
  File "/opt/android_sdk/ndk/25.1.8937393/prebuilt/darwin-x86_64/bin/ndk-stack.py", line 364, in main
    for line in args.input:
  File "/opt/android_sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/darwin-x86_64/python3/lib/python3.9/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 1177: invalid start byte

Affected versions

r26

Canary version

No response

Host OS

Mac

Host OS version

macOS 14.2.1

Affected ABIs

arm64-v8a

Build system

CMake

Other build system

No response

minSdkVersion

21

Device API level

32

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions