https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121876

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Malcolm <[email protected]>:

https://gcc.gnu.org/g:38cb4289180d13a71c2e1005223f442747bcf56e

commit r16-3827-g38cb4289180d13a71c2e1005223f442747bcf56e
Author: David Malcolm <[email protected]>
Date:   Fri Sep 12 10:24:36 2025 -0400

    diagnostics: fix crash-handling inside nested diagnostics [PR121876]

    PR diagnostics/121876 tracks an issue inside our crash-handling, where
    if an ICE happens when we're within a nested diagnostic, an assertion
    fails inside diagnostic::context::set_diagnostic_buffer, leading to
    a 2nd ICE.  Happily, this does not infinitely recurse, but it obscures
    the original ICE and the useful part of the backtrace, and any SARIF or
    HTML sinks we were writing to are left as empty files.

    This patch tweaks the above so that the assertion doesn't fail, and adds
    test coverage (via a plugin) to ensure that such ICEs/crashes are
    gracefully handled and e.g. captured in SARIF/HTML output.

    gcc/ChangeLog:
            PR diagnostics/121876
            * diagnostics/buffering.cc (context::set_diagnostic_buffer): Add
            early reject of the no-op case.

    gcc/testsuite/ChangeLog:
            PR diagnostics/121876
            * gcc.dg/plugin/crash-test-nested-ice-html.py: New test.
            * gcc.dg/plugin/crash-test-nested-ice-sarif.py: New test.
            * gcc.dg/plugin/crash-test-nested-ice.c: New test.
            * gcc.dg/plugin/crash-test-nested-write-through-null-html.py: New
test.
            * gcc.dg/plugin/crash-test-nested-write-through-null-sarif.py: New
test.
            * gcc.dg/plugin/crash-test-nested-write-through-null.c: New test.
            * gcc.dg/plugin/crash_test_plugin.cc: Add "nested" argument, and
when
            set, inject the problem within a nested diagnostic.
            * gcc.dg/plugin/plugin.exp: Add crash-test-nested-ice.c and
            crash-test-nested-write-through-null.c.

    Signed-off-by: David Malcolm <[email protected]>

Reply via email to