gbranden pushed a commit to branch master
in repository groff.

commit 88ae2c8f6db0e2bb4608ebda7b098dccadf89dd6
Author: G. Branden Robinson <[email protected]>
AuthorDate: Tue Apr 22 21:51:43 2025 -0500

    [troff]: Improve stack overflow fatal diagnostic.
    
    When input blows out the stack, say how big it was.
    
    * src/roff/troff/input.cpp (input_stack::push, input_stack::next_file):
      In fatal diagnostics complaining of excessive *roff language stack use
      (not the process stack), say how many levels of stack were configured.
---
 ChangeLog                | 9 +++++++++
 src/roff/troff/input.cpp | 5 +++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b95918a00..7c08d4cb7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2025-04-22  G. Branden Robinson <[email protected]>
+
+       [troff]: When input blows out the stack, say how big it was.
+
+       * src/roff/troff/input.cpp (input_stack::push)
+       (input_stack::next_file): In fatal diagnostics complaining of
+       excessive *roff language stack use (not the process stack), say
+       how many levels of stack were configured.
+
 2025-04-21  G. Branden Robinson <[email protected]>
 
        [troff]: Fix build failure with Clang 20, GCC 9.3 and likely
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index fd25620ab..46e8e3da8 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -714,7 +714,8 @@ void input_stack::push(input_iterator *in)
   if (in == 0)
     return;
   if (++level > limit && limit > 0)
-    fatal("input stack limit exceeded (probable infinite loop)");
+    fatal("input stack limit of %1 levels exceeded"
+         " (probable infinite loop)", limit);
   in->next = top;
   top = in;
   if (top->is_diversion) {
@@ -839,7 +840,7 @@ void input_stack::next_file(FILE *fp, const char *s)
     if ((*pp)->next_file(fp, s))
       return;
   if (++level > limit && limit > 0)
-    fatal("input stack limit exceeded");
+    fatal("input stack limit of %1 levels exceeded", limit);
   *pp = new file_iterator(fp, s);
   (*pp)->next = &nil_iterator;
 }

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to