-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[compiler-rt] Fixed Android 8.1 getauxval(AT_PAGESZ) crashes if called from .preinit_array. (#113427)
#116121
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
Conversation
|
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
getauxval(AT_PAGESZ) crashes if called from .preinit_array. #113427 getauxval(AT_PAGESZ) crashes if called from .preinit_array. (#113427)
fmayer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change status of PR from "Draft"
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
|
@DanAlbert does this LGTY from NDK perspective to use a weak symbol to runtime detect API level? |
|
@llvm/pr-subscribers-compiler-rt-sanitizer Author: None (funsafe-ptr) ChangesFull diff: https://github.com/llvm/llvm-project/pull/116121.diff 1 Files Affected:
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
index 04b095dca904ab..344b16be4a96e0 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -82,6 +82,12 @@
# include <sys/personality.h>
# endif
+# if SANITIZER_ANDROID && __ANDROID_API__ < 35
+// The weak strerrorname_np definition allows to check for the API level at
+// runtime.
+extern "C" SANITIZER_WEAK_ATTRIBUTE const char* strerrorname_np(int);
+# endif
+
# if SANITIZER_LINUX && defined(__loongarch__)
# include <sys/sysmacros.h>
# endif
@@ -1237,6 +1243,13 @@ uptr GetPageSize() {
CHECK_EQ(rv, 0);
return (uptr)pz;
# elif SANITIZER_USE_GETAUXVAL
+# if SANITIZER_ANDROID && __ANDROID_API__ < 35
+ // The 16 KB page size was introduced in Android 15, while earlier versions
+ // of Android used a 4 KB page size.
+ if (!strerrorname_np)
+ return 4096;
+# endif
+
return getauxval(AT_PAGESZ);
# else
return sysconf(_SC_PAGESIZE); // EXEC_PAGESIZE may not be trustworthy.
|
|
FYI: "This commit is not signed, but one or more authors requires that any commit attributed to them is signed." |
75d2845 to
d7ce33f
Compare
…led from `.preinit_array`. (llvm#113427)
Signed-off-by: funsafe-ptr <[email protected]>
d7ce33f to
8997cc5
Compare
|
I tested it on Termux using Android 8.1. termux/termux-packages#22369 (comment) |
23e6a62 to
08d3387
Compare
This reverts commit 771698b.
|
Ping |
|
@DanAlbert please confirm this makes sense to you. thanks! |
|
@DanAlbert Ping |
1 similar comment
|
@DanAlbert Ping |
|
NDK r28 has been released. I am pretty sure this issue has been forgotten. |
|
@DanAlbert given so much time has passed, I merged this. Please let me know in case you have strong disagreements. |
|
@funsafe-ptr Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
…lled from `.preinit_array`. (llvm#113427) (llvm#116121) Signed-off-by: funsafe-ptr <[email protected]>
No description provided.