Skip to content
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

[compiler-rt] fix BSD procmaps stack size limit on build due to the k… #82887

Merged

Conversation

devnexen
Copy link
Member

…info_proc type.

@llvmbot
Copy link
Collaborator

llvmbot commented Feb 24, 2024

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

Author: David CARLIER (devnexen)

Changes

…info_proc type.


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

1 Files Affected:

  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cpp (+7-4)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cpp
index dcfd94fe3225cd..3649bfd1b25b12 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_bsd.cpp
@@ -37,10 +37,13 @@ void GetMemoryProfile(fill_profile_f cb, uptr *stats) {
     getpid()
   }; 
 
-  struct kinfo_proc InfoProc;
-  uptr Len = sizeof(InfoProc);
-  CHECK_EQ(internal_sysctl(Mib, ARRAY_SIZE(Mib), nullptr, (uptr *)&InfoProc, &Len, 0), 0);
-  cb(0, InfoProc.ki_rssize * GetPageSizeCached(), false, stats);
+  struct kinfo_proc *InfoProc;
+  uptr Len = sizeof(*InfoProc);
+  uptr Size = Len;
+  InfoProc = (struct kinfo_proc *)MmapOrDie(Size, "GetMemoryProfile()");
+  CHECK_EQ(internal_sysctl(Mib, ARRAY_SIZE(Mib), nullptr, (uptr *)InfoProc, &Len, 0), 0);
+  cb(0, InfoProc->ki_rssize * GetPageSizeCached(), false, stats);
+  UnmapOrDie(InfoProc, Size, true);
 }
 #endif
 

Copy link

github-actions bot commented Feb 24, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@devnexen devnexen force-pushed the compiler_rt_fix_stacklimit_procmaps_bsd branch 2 times, most recently from eb459b6 to c0f2c50 Compare February 26, 2024 17:31
@@ -30,17 +30,17 @@ namespace __sanitizer {

#if SANITIZER_FREEBSD
void GetMemoryProfile(fill_profile_f cb, uptr *stats) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

stack size of stack frame size limit?
if the latter, maybe noinline on the function is better fix?

Copy link
Member Author

Choose a reason for hiding this comment

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

if you meant adding NOINLINE it fixes nothing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

would it be possible fixup title to avoid line break?

How bit this struct? Or what is error message?

I would prefer RAII with InternalScopedVector<kinfo_proc> of size 1

Copy link
Member Author

Choose a reason for hiding this comment

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

would it be possible fixup title to avoid line break?

How bit this struct? Or what is error message?

1088 :)

@devnexen devnexen force-pushed the compiler_rt_fix_stacklimit_procmaps_bsd branch from c0f2c50 to 31119c3 Compare March 1, 2024 01:12
@devnexen devnexen merged commit 7ceb74f into llvm:main Mar 1, 2024
4 checks passed
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.

None yet

3 participants