Follow-up Comment #1, bug #68192 (group groff):

Already underway.


commit 254b4d8d6f2beb8d368fd7cc02d460ed936ffddc
Author: G. Branden Robinson <[email protected]>
Date:   Thu Jul 10 16:53:54 2025 -0500

    [pre-grohtml]: Handle memory exhaustion.
    
    * src/preproc/html/pre-html.cpp (get_line): Catch `std::bad_alloc`
      exceptions from `new` operator.  Throw a fatal error indicating how
      much memory we couldn't allocate and which line of which file we were
      reading when we had trouble.
    
    Exhibit:
    
    $ rm build/font/devps/DESC
    $ make -C build font/devps/DESC
    [output elided]
    $ printf 'papersize ' >> build/font/devps/DESC
    $ dd if=/dev/zero of=/dev/stdout bs=1M count=8192 \
      | tr '\0' '@' >> build/font/devps/DESC
    [output elided]
    $ printf '\n' >> build/font/devps/DESC
    $ make -C build
      GROFF    doc/pic.html
    pre-grohtml:.../build/font/devps/DESC:15: fatal error: cannot allocate
more than 1073741824 bytes to read line; aborting
    
    And with that, groff takes another step away from Annotated Reference
    Manual C++ and into the bleeding-edge horizons of ISO C++98.


(The young me of July 2025 didn't realize that Stroustrup was already trying
to get C++ programmers to use exceptions in the late 1980s.  I wonder when
_cfront_ added support for them.)


commit 21c8b8e7497e9e4c3511baf7eb55525fba0241d0
Author: G. Branden Robinson <[email protected]>
Date:   Thu Jul 10 20:58:38 2025 -0500

    [troff]: Catch `std::bad_alloc` exceptions (1/3).
    
    ...from `new` operator.  Throw a fatal error indicating how much memory
    we couldn't allocate.
    
    * src/roff/troff/input.cpp (read_long_escape_parameters): Do it.
    
    Exhibit:
    
    $ { printf '\\['; dd if=/dev/zero of=/dev/stdout bs=1M count=1024 \
        | tr '\0' 'a'; printf ']\n'; } | ./build/test-groff -z
    1024+0 records in
    1024+0 records out
    1073741824 bytes (1.1 GB, 1.0 GiB) copied, 12.3334 s, 87.1 MB/s
    troff:<standard input>:1: fatal error: cannot allocate 1073741824 bytes to
read input line

commit 3d3ee76860e050750d29a25eb2f648b04bf13894
Author: G. Branden Robinson <[email protected]>
Date:   Thu Jul 10 21:10:38 2025 -0500

    [troff]: Catch `std::bad_alloc` exceptions (2/3).
    
    ...from `new` operator.  Throw a fatal error indicating how much memory
    we couldn't allocate.
    
    * src/roff/troff/input.cpp (do_get_long_name): Do it.
    
    Exhibit:
    
    $ { printf '.defcolor fuchsia'; \
        dd if=/dev/zero of=/dev/stdout bs=1M count=1024 | tr '\0' 'a'; \
        printf ' rgb #fe00fe\n'; } | ./build/test-groff
    1024+0 records in
    1024+0 records out
    1073741824 bytes (1.1 GB, 1.0 GiB) copied, 9.87108 s, 109 MB/s
    troff:<standard input>:1: fatal error: cannot allocate 1073741824 bytes to
read input line

commit c390daadefc502826338da055c7bd9ba9be79d1b
Author: G. Branden Robinson <[email protected]>
Date:   Thu Jul 10 21:02:08 2025 -0500

    [troff]: Catch `std::bad_alloc` exceptions (3/3).
    
    ...from `new` operator.  Throw a fatal error indicating how much memory
    we couldn't allocate.
    
    * src/roff/troff/input.cpp (get_delimited_name): Do it.
    
    Exhibit:
    
    $ { printf '\\C@'; dd if=/dev/zero of=/dev/stdout bs=1M count=1024 \
        | tr '\0' 'a'; printf '@\n'; } | ./build/test-groff
    1024+0 records in
    1024+0 records out
    1073741824 bytes (1.1 GB, 1.0 GiB) copied, 10.1333 s, 106 MB/s
    troff:<standard input>:1: fatal error: cannot allocate 1073741824 bytes to
read input line

commit c74bf804f79d6f176120a42c757701a34fc489c6
Author: G. Branden Robinson <[email protected]>
Date:   Mon Dec 8 04:21:14 2025 -0600

    [troff]: Continue working on bug #67735.
    
    * src/roff/troff/input.cpp: Migrate more input character reading
      functions to deal in the type `unsigned char` rather than `char`.
    
      (do_get_long_name): Update declaration.
    
      (read_rgb, read_cmy, read_cmyk, read_gray, do_get_long_name): Update
      definitions.
    
      (get_long_name): Update `do_get_long_name()` call site to use literal
      of `unsigned char` rathern than `char` type.
    
      (do_get_long_name): Change type of local variable `buf` from `char` to
      `unsigned char`, since it is directly populated by reads of bytes from
      the input stream.  This function converts said input into an object of
      the groff class `symbol` and returns it, but `symbol` has no
      constructor accepting a pointer to `const unsigned char`.
      Consequently, once we have successfuly populated `buf`, create a new
      buffer `chbuf`, a heap-allocated array of `char` type.  Free this
      array after constructing a `symbol` on the stack.  (If all this seems
      like rigmarole, consider that it's going to be necessary anyway when
      we read bytes from the input stream, confirm that they're valid UTF-8
      sequences, apply Normalization Form D decomposition, and then store
      them as one or more 32-bit code points in GNU troff's planned future
      internal character data type.  See Savannah #40720.)
    
      (read_drawing_command_color_arguments): Change type of `end` local
      variable from `int` to `unsigned char`, since that is what the
      `read_{rgb,cmy,cmyk,gray}()` functions now expect as arguments.
    
    Continues the long process of fixing Savannah #67735.




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?68192>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

Attachment: signature.asc
Description: PGP signature

Reply via email to