-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Add cmake option to enable/disable searching PATH for symbolizer #129012
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
Add cmake option to enable/disable searching PATH for symbolizer #129012
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. |
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Midhunesh (midhuncodes7) ChangesIntroduced cmake option that is disabled by default allowing searching PATH variable for symbolizer. The option will be enabled for downstream changes to disable searching PATH variable for symbolizer instead use ASAN_SYMBOLIZER_PATH Full diff: https://github.com/llvm/llvm-project/pull/129012.diff 2 Files Affected:
diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index 2c52788de56af..67133b62cd047 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -830,6 +830,13 @@ pythonize_bool(COMPILER_RT_TEST_USE_LLD)
option(COMPILER_RT_ENABLE_INTERNAL_SYMBOLIZER "Build Compiler RT linked with in LLVM symbolizer" OFF)
mark_as_advanced(COMPILER_RT_ENABLE_INTERNAL_SYMBOLIZER)
+option(SANITIZER_DISABLE_SYMBOLIZER_PATH_SEARCH "Disable searching for external symbolizer in $PATH" OFF)
+mark_as_advanced(SANITIZER_DISABLE_SYMBOLIZER_PATH_SEARCH)
+
+if (SANITIZER_DISABLE_SYMBOLIZER_PATH_SEARCH)
+ add_compile_definitions(SANITIZER_DISABLE_SYMBOLIZER_PATH_SEARCH)
+endif()
+
add_subdirectory(lib)
if(COMPILER_RT_INCLUDE_TESTS)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
index 0ddc24802d216..7febcf6d4ff00 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
@@ -443,23 +443,28 @@ static SymbolizerTool *ChooseExternalSymbolizer(LowLevelAllocator *allocator) {
}
// Otherwise symbolizer program is unknown, let's search $PATH
+#ifdef SANITIZER_DISABLE_SYMBOLIZER_PATH_SEARCH
+ VReport(2, "Symbolizer path search is disabled in the runtime build configuration\n");
+ return nullptr;
+#else
CHECK(path == nullptr);
-#if SANITIZER_APPLE
- if (const char *found_path = FindPathToBinary("atos")) {
- VReport(2, "Using atos found at: %s\n", found_path);
- return new(*allocator) AtosSymbolizer(found_path, allocator);
- }
-#endif // SANITIZER_APPLE
- if (const char *found_path = FindPathToBinary("llvm-symbolizer")) {
- VReport(2, "Using llvm-symbolizer found at: %s\n", found_path);
- return new(*allocator) LLVMSymbolizer(found_path, allocator);
- }
- if (common_flags()->allow_addr2line) {
- if (const char *found_path = FindPathToBinary("addr2line")) {
- VReport(2, "Using addr2line found at: %s\n", found_path);
- return new(*allocator) Addr2LinePool(found_path, allocator);
+ #if SANITIZER_APPLE
+ if (const char *found_path = FindPathToBinary("atos")) {
+ VReport(2, "Using atos found at: %s\n", found_path);
+ return new(*allocator) AtosSymbolizer(found_path, allocator);
}
- }
+ #endif // SANITIZER_APPLE
+ if (const char *found_path = FindPathToBinary("llvm-symbolizer")) {
+ VReport(2, "Using llvm-symbolizer found at: %s\n", found_path);
+ return new(*allocator) LLVMSymbolizer(found_path, allocator);
+ }
+ if (common_flags()->allow_addr2line) {
+ if (const char *found_path = FindPathToBinary("addr2line")) {
+ VReport(2, "Using addr2line found at: %s\n", found_path);
+ return new(*allocator) Addr2LinePool(found_path, allocator);
+ }
+ }
+#endif // SANITIZER_DISABLE_SYMBOLIZER_PATH_SEARCH
return nullptr;
}
|
Can you please elaborate what kind of issues you have from symbolizer? |
✅ With the latest revision this PR passed the C/C++ code formatter. |
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.
When compiling with this new CMake flag on, how are tests expected to pass? That is, there probably should be changes made to the testing to set up the environment variables necessary for the symbolizer to be invoked from the tests.
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
Outdated
Show resolved
Hide resolved
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
Outdated
Show resolved
Hide resolved
Disabling the search via |
…dhuncodes7/llvm-project into midhun7/symbolizer-PATH-search-option
We usually do not recommend to use sanitizers with heaver runtime in environment sensitive to such vulnerabilities. |
Understood. However, I think it would be reasonable (as a choice by the builder of the sanitizer) to recommend against deploying said sanitizers to environments thought to be sensitive to such vulnerabilities and yet also configure the sanitizers to be less susceptible to such vulnerabilities. |
SGTM. |
Will do; thanks! |
@midhuncodes7, I would recommend not pushing merge-from-upstream commits to a PR branch if there was no manual merge resolution needed and no substantive change to the PR. The push causes notification noise for reviewers. |
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.
LGTM with minor comment.
@vitalybuka, I believe that this is ready for your review.
@midhuncodes7, please wait for additional reviews before merging.
compiler-rt/test/sanitizer_common/TestCases/disable_symbolizer_path_search.cpp
Outdated
Show resolved
Hide resolved
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.
Another minor issue. Sorry for missing this earlier.
Otherwise LGTM.
@vitalybuka, we're looking forward to your review.
compiler-rt/test/sanitizer_common/TestCases/disable_symbolizer_path_search.cpp
Outdated
Show resolved
Hide resolved
✅ With the latest revision this PR passed the Python code formatter. |
…dep.cpp (llvm#133011)" This reverts commit 03817f0.
…symbolizer-PATH-search-option
@midhuncodes7 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! |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/195/builds/6720 Here is the relevant piece of the build log for the reference
|
llvm/llvm-project#129012 added a new CMake flag. This flag is used by IBM's downstream builds. This patch sets the flag on the community buildbot for AIX to ensure upstream coverage and visibility.
llvm/llvm-project#129012 added a new CMake flag. This flag is used by IBM's downstream builds. This patch sets the flag on the community buildbots (Clang and Flang) for AIX to ensure upstream coverage and visibility.
Introduced a cmake option that is disabled by default that suppresses searching via the PATH variable for a symbolizer. The option will be enabled for downstream builds where the user will need to specify the symbolizer path more explicitly, e.g., by using ASAN_SYMBOLIZER_PATH.