Skip to content

[win/asan] Avoid warnings in interception_win.cpp. #118143

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

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

bernhardu
Copy link
Contributor

warning: format specifies type 'void *' but the argument has type 'uptr' (aka 'unsigned long long') [-Wformat] (observed at x86_64, in AllocateTrampolineRegion)

warning: format specifies type 'char *' but the argument has type 'RVAPtr' [-Wformat] (observed at x86_64, in InternalGetProcAddress)

warning: format specifies type 'void *' but the argument has type 'uptr' (aka 'unsigned long long') [-Wformat]
(observed at x86_64, in AllocateTrampolineRegion)

warning: format specifies type 'char *' but the argument has type 'RVAPtr<char>' [-Wformat]
(observed at x86_64, in InternalGetProcAddress)
@llvmbot
Copy link
Member

llvmbot commented Nov 29, 2024

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: None (bernhardu)

Changes

warning: format specifies type 'void *' but the argument has type 'uptr' (aka 'unsigned long long') [-Wformat] (observed at x86_64, in AllocateTrampolineRegion)

warning: format specifies type 'char *' but the argument has type 'RVAPtr<char>' [-Wformat] (observed at x86_64, in InternalGetProcAddress)


Full diff: https://github.com/llvm/llvm-project/pull/118143.diff

1 Files Affected:

  • (modified) compiler-rt/lib/interception/interception_win.cpp (+2-2)
diff --git a/compiler-rt/lib/interception/interception_win.cpp b/compiler-rt/lib/interception/interception_win.cpp
index dc3018a675dee2..93886e79fd88c8 100644
--- a/compiler-rt/lib/interception/interception_win.cpp
+++ b/compiler-rt/lib/interception/interception_win.cpp
@@ -418,7 +418,7 @@ static void *AllocateTrampolineRegion(uptr min_addr, uptr max_addr,
   ReportError(
       "interception_win: AllocateTrampolineRegion failed to find free memory; "
       "min_addr: %p, max_addr: %p, func_addr: %p, granularity: %zu\n",
-      (void *)min_addr, (void *)max_addr, granularity);
+      (void *)min_addr, (void *)max_addr, (void *)func_addr, granularity);
   return nullptr;
 #else
   return ::VirtualAlloc(nullptr,
@@ -1247,7 +1247,7 @@ uptr InternalGetProcAddress(void *module, const char *func_name) {
         char function_name[256];
         size_t funtion_name_length = _strlen(func);
         if (funtion_name_length >= sizeof(function_name) - 1) {
-          ReportError("interception_win: func too long: '%s'\n", func);
+          ReportError("interception_win: func too long: '%s'\n", (char *)func);
           InterceptionFailed();
         }
 

@bernhardu
Copy link
Contributor Author

Hello @zmodem, does this PR also qualify for a review?

Copy link
Collaborator

@zmodem zmodem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @zmodem, does this PR also qualify for a review?

Absolutely, I just didn't see it before. Please feel free to @ me for any asan PRs you send.

@@ -418,7 +418,7 @@ static void *AllocateTrampolineRegion(uptr min_addr, uptr max_addr,
ReportError(
"interception_win: AllocateTrampolineRegion failed to find free memory; "
"min_addr: %p, max_addr: %p, func_addr: %p, granularity: %zu\n",
(void *)min_addr, (void *)max_addr, granularity);
(void *)min_addr, (void *)max_addr, (void *)func_addr, granularity);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Nice find :)

@zmodem zmodem merged commit 055f1a7 into llvm:main Dec 6, 2024
10 checks passed
@bernhardu bernhardu deleted the mr-interception_win-cleanup_warning branch December 6, 2024 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants