[bug #68340] [troff] ASAN runtime error when formatting groff_mdoc(7) in troff mode: ../src/roff/troff/input.cpp:4006:22

"G. Branden Robinson" <[email protected]>
Newsgroups gmane.comp.printing.groff.bugs
Message-ID <[email protected]>
Update of bug #68340 (group groff):

                  Status:             In Progress => Fixed
             Open/Closed:                    Open => Closed

    _______________________________________________________

Follow-up Comment #2:


commit fb2432fe60225d6c34e43b630e67cbc1c24e61d5
Author: G. Branden Robinson <[email protected]>
Date:   Sun May 17 14:32:33 2026 -0500

    [troff]: Remove heap-overreading optimization.
    
    * src/roff/troff/input.cpp (char_list::get): De-optimize read access at
      the end of a `char_list`, because the pointer arithmetic used can
      access heap storage beyond the end of the underlying `char_block` used
      to house the list.
    
    Fixes <https://savannah.gnu.org/bugs/?68340>.  Resolves ASAN runtime
    error when formatting the groff_mdoc(7) man page in troff mode.  Thanks
    to Bjarni Ingi Gislason for the report.
    
    Performance analysis
    ====================
    
    This change slows groff pipline operation by about 5% across the corpus
    of documents produced in its own build.  If someone would like to craft
    a new, more memory-safe optimization to recover the performance, please
    contact the groff at gnu dot org mailing list and share your proposal.
    
    (A better long-term fix might be to migrate `char_list` to an ISO C++98
    STL templated container type; these are often performance-tuned already
    by the compiler vendor.)
    
    $ cat measure.bash
    shopt -s extglob
    
    make -C build -j >/dev/null 2>&1
    
    for n in $(seq 20)
    do
            rm -f build/doc/!(groff).pdf build/doc/*.ps \
                    build/doc/!(groff).html \
                    build/contrib/hdtbl/examples/*.ps \
                    build/contrib/mom/examples/*.pdf \
                    contrib/sboxes/msboxes.pdf \
                    doc/groff-man-pages.utf8.txt
            t=$({ time -p make -C build >/dev/null 2>&1; } 2>/dev/stdout)
            echo "$t" | awk '/real/ { print $2; }'
    done
    
    Before
    ------
    
    $ bash ./measure.bash | tee | datamash range 1 mean 1 sstdev 1
    0.86    31.9025 0.24063239052218
    
    After
    -----
    
    $ bash ./measure.bash | tee | datamash range 1 mean 1 sstdev 1
    6.91    33.545  1.8817363202498




    _______________________________________________________

Reply to this item at:

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

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc (application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE-----

iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCahPhzgAKCRCqLAuaBUf3
TgNLAQDTZaF60v8PzNW79DLwVQX5Xbc5SU0+I9Q9AfJtclN5AAEAmWLRwwjT19rL
rz2q3eEJOLHTHrVun8m6lKjzfmQNVgQ=
=ouDT
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.