Fixed
Status Update
Comments
ar...@google.com <ar...@google.com> #2
Err, I have no idea how gerrit changesets are reflected in the bug report, but there is a preliminary patch https://android-review.googlesource.com/#/c/159020/
em...@gmail.com <em...@gmail.com> #3
Scope of changes to bionic are somewhat more complex than initially thought.
The troublesome spots are mmap() and friends, malloc() and friends (due to symbol clash between struct, fieldname, and function names) as well as most of the routines in string.h
string.h exposes some issues, because the routines in it are both defined as inline functions that call out to assembly counterpart of the same name using an inconsistent __builtin_XXXX() convention. Sometimes the routines are available as _builtin___XXXX_chk and sometimes as __builtin_xxx.
I initially thought about limiting the macro magic purely for bionic/arm64, but there does not seem to be a nice way to do this.
Does this mean I need to touch all the .S files that are associated with string.h?
Even for the ones that are NOT for arm64?
Please take a look at:
https://code.google.com/p/android/issues/detail?id=180578
The troublesome spots are mmap() and friends, malloc() and friends (due to symbol clash between struct, fieldname, and function names) as well as most of the routines in string.h
string.h exposes some issues, because the routines in it are both defined as inline functions that call out to assembly counterpart of the same name using an inconsistent __builtin_XXXX() convention. Sometimes the routines are available as _builtin___XXXX_chk and sometimes as __builtin_xxx.
I initially thought about limiting the macro magic purely for bionic/arm64, but there does not seem to be a nice way to do this.
Does this mean I need to touch all the .S files that are associated with string.h?
Even for the ones that are NOT for arm64?
Please take a look at:
ar...@google.com <ar...@google.com> #4
Could you please reiterate why is it not possible to fix this in TSan? If the problem is some call happening before __tsan_init, we just need to call __tsan_init right there. Most (if not all) interceptors have this logic.
Does it still happen if __tsan_init is called from .preinit_array?
Does it still happen if __tsan_init is called from .preinit_array?
em...@gmail.com <em...@gmail.com> #5
Its troublesome before __tsan_init because we lack __thread keyword support in bionic. I had to hack in a workaround in TSAN that does not use intercepted calls. (more on this below)
The majority of the problem actually occurs after __tsan_init has been called.
For example, pthread_create() calls a bunch of routines for the *new thread*, before it has had a chance to initialize its ThreadState. All of these routines running on the new thread are intercepted by tsan, and crashes because ThreadState has not been initialized yet.
A purely tsan-only fix is to "globally ignore" interceptors during troublesome times. This works fine for two threads, but doesn't scale to multiple threads - now you can miss events because they are being ignored.
I also tried putting in "global partial ignores" (i.e. ignore interceptors only on the new thread), but that got really hairy as well.
The fundamental problem is that TSAN is intercepting calls that it has no business intercepting.
For example, the same thing happens during thread join time, when one thread is being deconstructed.
Similar things happen during process exit time where ALL threads are being deconstructed.
Playing around with purely TSAN solution, all I managed to do was move around the actual place of the crash/hang/missed events.
The majority of the problem actually occurs after __tsan_init has been called.
For example, pthread_create() calls a bunch of routines for the *new thread*, before it has had a chance to initialize its ThreadState. All of these routines running on the new thread are intercepted by tsan, and crashes because ThreadState has not been initialized yet.
A purely tsan-only fix is to "globally ignore" interceptors during troublesome times. This works fine for two threads, but doesn't scale to multiple threads - now you can miss events because they are being ignored.
I also tried putting in "global partial ignores" (i.e. ignore interceptors only on the new thread), but that got really hairy as well.
The fundamental problem is that TSAN is intercepting calls that it has no business intercepting.
For example, the same thing happens during thread join time, when one thread is being deconstructed.
Similar things happen during process exit time where ALL threads are being deconstructed.
Playing around with purely TSAN solution, all I managed to do was move around the actual place of the crash/hang/missed events.
ar...@google.com <ar...@google.com> #6
On x86_64/linux, precisely zero calls are intercepted during pthread_create() on the new thread until it has finished initializing its ThreadState.
That does not happen on aarch64/bionic
That does not happen on aarch64/bionic
em...@gmail.com <em...@gmail.com> #7
Oh, the reason why I had to hack in a non-interceptible TLS workaround was that intercepted calls happen during pthread_key maintenance that occurs both during pthread_join time as well as at exit time.
What was happening when I was using pthread_get/setspecific() was that after a thread was destroyed, an intercepted call was GENERATING a NEW key for the dead thread. Hilarity ensued afterwards.
What was happening when I was using pthread_get/setspecific() was that after a thread was destroyed, an intercepted call was GENERATING a NEW key for the dead thread. Hilarity ensued afterwards.
ma...@gmail.com <ma...@gmail.com> #8
Back to the topic at hand,
does anyone have any ideas on how to limit the bionic headerfile changes purely for aarch64?
https://code.google.com/p/android/issues/detail?id=180578
I *think* it might be better to limit the new internal symbols to 64bit arm parts, but there does not seem to be a nice way to do this (yet).
While my build currently "works", I don't think it will build for other platforms (i.e. 32bit arm, mips etc...)
Thanks
does anyone have any ideas on how to limit the bionic headerfile changes purely for aarch64?
I *think* it might be better to limit the new internal symbols to 64bit arm parts, but there does not seem to be a nice way to do this (yet).
While my build currently "works", I don't think it will build for other platforms (i.e. 32bit arm, mips etc...)
Thanks
is...@google.com <is...@google.com>
an...@gmail.com <an...@gmail.com> #9
It looks like __aarch64__ is defined for Clang builds. I am not sure about gcc, nor can I say that the bionic folks are going to be pleased with architecture-specific stuff polluting high-level headers.
sa...@google.com <sa...@google.com> #10
@11: i think he's confused and expecting __aarch64__ to be defined in code that's built 32-bit.
Description
1. Initiate a connection to a Bluetooth Low Energy device, with the autoConnect parameter set to false. Make sure the remote peripheral does not advertise at the moment.
2. After a while but before the 30s timeout, call close() on the gatt object (without calling disconnect() before). Or alternatively just swipe-close the app.
3. Now start the advertising on the peripheral (before the 30s timeout).
Expected outcome:
The peripheral should not connect since the Android device should have aborted the connection attempt.
What happens instead:
The device connects. No app is using the connection however.
This happens since Android N (version NPD56N, NPD90G, NRD90S). It did not happen earlier (in Android 6.0.1).
Note: it only happens when the autoConnect parameter is set to false.