-
Notifications
You must be signed in to change notification settings - Fork 257
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
SEGV in __gnu_Unwind_Resume during exception propagation when ASan is used #613
Comments
I've hit this identical issue in my own code. It seems that asan in these NDK is built with older libc++ exception code relying on libunwind while new libc++_shared exception unwinding code uses same method as gnustl. This makes the unwinder explode whenever it is triggered and asan is enabled. |
TLDR: This is a bug with ASAN in r16b that should be fixed in r17.
Yeah, this is a problem. When building for ARM32, using the libc++ STL, application binaries need to use their own statically-linked copy of LLVM's libunwind. If the The root problem is that the
The NDK binaries are linked with LLVM's
The unwinder symbols are hidden in r17:
The test case in #615 passes with r17, too. |
I have a libA.so and libA_wrapper.so
A exception is thrown in libA and is caught in libA_wrapper
Depending on where in libA this exception is thrown, SEGV may occur in ASan's internal exception handler.
In this case, the PC is libclang_rt.asan-arm-android.so+0xa7a77,
which is 000a7a70 <__gnu_Unwind_Resume>+0x7 (libclang_rt.asan-arm-android.so is pushed to the device by /ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/asan_device_setup).
Initially I thought this was caused by #289 ,
but I checked my libA and libA_wrapper and I only see :
arm-linux-androideabi-readelf -sW libA.so | grep _Unwind
41: 00000000 0 FUNC GLOBAL DEFAULT UND _Unwind_Resume
10477: 00000000 0 FUNC GLOBAL DEFAULT UND _Unwind_Resume
even if I added "unwind" (libunwind,a) as the first library in target_link_libraries().
Then I thought this is an issue caused by passing exceptions across shared library boundary, so I changed libA to a static library and at run time there will only be libA_wrapper.so that contains both, but I will still get the same result.
Log from the application:
01-08 16:03:08.747 10180 10301 I : =================================================================
01-08 16:03:08.748 10180 10301 I :
01-08 16:03:08.748 10180 10301 I :
01-08 16:03:08.748 10180 10301 I : ==10180==ERROR: AddressSanitizer: SEGV on unknown address 0x0000000e (pc 0xa68e5a78 bp 0x987febd8 sp 0x987fc190 T543)
01-08 16:03:08.748 10180 10301 I :
01-08 16:03:08.748 10180 10301 I :
01-08 16:03:08.748 10180 10301 I : ==10180==The signal is caused by a READ memory access.
01-08 16:03:08.748 10180 10301 I :
01-08 16:03:08.748 10180 10301 I : ==10180==Hint: address points to the zero page.
01-08 16:03:08.748 10180 10301 I :
01-08 16:03:08.920 10180 10301 I : #0 0xa68e5a77 (/system/lib/libclang_rt.asan-arm-android.so+0xa7a77)
01-08 16:03:08.920 10180 10301 I :
01-08 16:03:08.921 10180 10301 I :
01-08 16:03:08.921 10180 10301 I :
01-08 16:03:08.922 10180 10301 I : AddressSanitizer can not provide additional info.
I'm positive that this segv does not come from user code, which is a early version of this:
https://github.com/glassechidna/zxing-cpp/blob/07e5600e56e5b9e3a5a78ccaea52fb4daf1c70ea/core/src/zxing/MultiFormatReader.cpp#L112
I tried to throw a dummy exception at the beginning of
Ref MultiFormatReader::decodeInternal(Ref image)
and I can not see the logs from Ref image's destructor, so the crash must have happened during stack unwinding.
This error does not happen when ASan is not installed.
Environment Details
Not all of these will be relevant to every bug, but please provide as much
information as you can.
The text was updated successfully, but these errors were encountered: