-
Notifications
You must be signed in to change notification settings - Fork 264
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
Clang only uses TLS for stack protector on x86 #297
Comments
Thanks for following up on this. Saw your SO post yesterday and was waiting to ask someone about it.
Completely agreed. One NDK should work for all of its supported targets. Your link is actually to a different message, btw, you wanted https://gcc.gnu.org/ml/gcc/2015-11/msg00060.html. I'm glad you did link that one though, because it does actually give a clue as to how to fix this. If you add |
If it turns out that is what we need (sounds like yes, so I'll go ahead and prepare the patch regardless), I'll add this to r14 since it's low risk. |
Thanks, the Thanks for the correction re: gcc maillist link, I fixed my text. |
Merged into r14. |
@DanAlbert is there a way to tune clang, too? I couldn't find the flag with r14β2
|
I'm not sure what Clang does with this. @enh or @stephenhines should know. |
I could not find a workaround on macOS. And if I understand correctly, this is an important question, because GCC is not supported anymore. |
i filed an internal clang bug (http://b/27494085) a while back that clang always uses TLS on x86/x86-64 and always uses the global on other architectures. afaik there's been no movement on that (though the bug implies that we might now have a clang that uses TLS for aarch64). regardless, clang has never to my knowledge offered the user a choice. |
FYI, patch for Clang is up for review now: https://reviews.llvm.org/D30276 Assuming that's submitted soon I'm guessing @stephenhines will be okay with cherry-picking this for r15? |
The change did get submitted, so we just need to make sure it gets cherry-picked into our next Clang build. |
Please let us know when this next Clang build will arrive.
…On Thu, Mar 2, 2017 at 19:28 Dan Albert ***@***.***> wrote:
The change did get submitted, so we just need to make sure it gets
cherry-picked into our next Clang build.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#297 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAs8s9i0TJ9nQLAcPgILOJXY8-TOX266ks5rhvwrgaJpZM4MAzhB>
.
|
https://gcc.gnu.org/ml/gcc/2015-11/msg00060.html changed the default for this from using a global to using the TLS slot. As noted in android/ndk#297 (and in that commit), this is not compatible with pre-4.2 devices, so we need to guard against that in the NDK. Test: ./validate.py --filter mstack-protector-guard Bug: android/ndk#297 Change-Id: I48152b452b210ed5d8967c3cb617e6fe97027b10 (cherry picked from commit 1f46cdf)
This patch was included in the update I just pushed to r15. Will be in beta 2. |
Oh, sweet! I was under false assumption that we need to specify |
https://gcc.gnu.org/ml/gcc/2015-11/msg00060.html changed the default for this from using a global to using the TLS slot. As noted in android/ndk#297 (and in that commit), this is not compatible with pre-4.2 devices, so we need to guard against that in the NDK. Test: ./validate.py --filter mstack-protector-guard Bug: android/ndk#297 Change-Id: I48152b452b210ed5d8967c3cb617e6fe97027b10
Description
http://stackoverflow.com/questions/42190295/stack-protection-triggered-by-eglmakecurrent/42233084
We have come across a weird device, named Motorla RAZR i, with x86 CPU and Android version 4.1.2 (circa 2013).
This device crashes sometimes on GL operations in native code. We finally reduced this error to just few lines of innocent function calls:
When compiled with
-fstack-protector-strong
(which is default if I understand correctly), calling this function on the specific device invariably causesBut if I use
-fno-stack-protector
, execution continues as if nothing bad happened. Which may (if I understand the situation correctly) become a trap for any further execution. Even more dangerous (because not explicit), adding -flto to CFLAGS hides the crash.In the code above, I removed error checking for brevity. Actually, all calls succeed. Also, the Cleanup section does not change the stack thrashing behavior of eglMakeCurrent(), but sometimes calling
eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)
before Cleanup, does help.TL;NR: this is a false alarm. The EGL library on the device (which was never updated since 2013) does not respect the TLS conventions that were introduced years later, and the new NDK (we use the stable r13) falsely blames our innocent function in stack smashing.
I found these (Nov 2015) https://gcc.gnu.org/ml/gcc/2015-11/msg00060.html and (Apr 2013): https://gcc.gnu.org/ml/gcc-patches/2013-04/msg00764.html
The assumption is wrong, our code runs same jar's and so's on all platforms from 4.0 to 7.0 and we don't want to use old versions of NDK for some of target devices. Actually, NDK r14 still provides support for android-9 (a.k.a. 2.3 GINGERBREAD).
Unfortunately, this means that at least on this device we must run the debug version of our C++ code with -fno-stack-protector. Luckily, our release build does not apply stack protector.
Environment Details
The text was updated successfully, but these errors were encountered: