Reduce stack usage when unwinding from 170 to 128 on x64

PiperOrigin-RevId: 830569454
Change-Id: If5f56cc64ad1f3fe2de45c273b2567ba6ebfe9ed
diff --git a/absl/debugging/stacktrace.cc b/absl/debugging/stacktrace.cc
index 420005c..557261e 100644
--- a/absl/debugging/stacktrace.cc
+++ b/absl/debugging/stacktrace.cc
@@ -80,11 +80,12 @@
                                                int skip_count, const void* uc,
                                                int* min_dropped_frames,
                                                bool unwind_with_fixup = true) {
-  static constexpr size_t kMinPageSize = 4096;
+  static constexpr size_t kMaxStackElements = 128;
 
-  // Allow up to ~half a page, leaving some slack space for local variables etc.
-  static constexpr size_t kMaxStackElements =
-      (kMinPageSize / 2) / (sizeof(*frames) + sizeof(*sizes));
+  static constexpr size_t kMinPageSize = 4096;
+  static_assert(
+      kMaxStackElements * (sizeof(*frames) + sizeof(*sizes)) < kMinPageSize / 2,
+      "buffer size should be a fraction of a page to avoid stack overflows");
 
   // Allocate a buffer dynamically, using the signal-safe allocator.
   static constexpr auto allocate = [](size_t num_bytes) -> void* {