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

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|-fanalyzer ICE with strtok  |[14/15/16/17 Regression]
                   |and malloc                  |-fanalyzer ICE with strtok
                   |                            |and malloc
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2026-12-03
           Keywords|                            |ice-on-valid-code
             Status|UNCONFIRMED                 |NEW

--- Comment #3 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Thanks for filing this bug report.

Confirmed that it still affects trunk: https://godbolt.org/z/c7qx4Enz6 which
shows a leak and then crashes here:
<source>: In function 'ice':
<source>:6:9: warning: leak of 'malloc(1)' [CWE-401] [-Wanalyzer-malloc-leak]
    6 |         strtok(malloc(1), " ");
      |         ^~~~~~~~~~~~~~~~~~~~~~
  'ice': events 1-2
    6 |         strtok(malloc(1), " ");
      |         ~~~~~~~^~~~~~~~~~~~~~~
      |         |      |
      |         |      (1) allocated here
      |         (2) ⚠️  'malloc(1)' leaks here; was allocated at (1)
during IPA pass: analyzer
<source>: At top level:
<source>:6:16: internal compiler error: Segmentation fault
0x29cc2b8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x29c0efb internal_error(char const*, ...)
        ???:0
0x2a35fe3 pretty_printer::format(text_info&)
        ???:0
0x2a38227 pp_printf(pretty_printer*, char const*, ...)
        ???:0
0x27fbc5b ana::poisoned_value_diagnostic::describe_final_event(pretty_printer&,
ana::evdesc::final_event const&)
        ???:0
0x27bf377 ana::warning_event::print_desc(pretty_printer&) const
        ???:0
0x27bfde7 ana::checker_event::prepare_for_emission(ana::checker_path*,
ana::pending_diagnostic*, diagnostic_event_id_t)
        ???:0
0x27e7e28 ana::diagnostic_manager::emit_saved_diagnostic(ana::exploded_graph
const&, ana::saved_diagnostic&)
        ???:0
0x27ec195 ana::dedupe_winners::emit_best(ana::diagnostic_manager*,
ana::exploded_graph const&)
        ???:0
0x27e8495 ana::diagnostic_manager::emit_saved_diagnostics(ana::exploded_graph
const&)
        ???:0
0x17d0df8 ana::impl_run_checkers(ana::logger*)
        ???:0
0x17d1ad6 ana::run_checkers()
        ???:0

and GCC 14-16, though those don't show the leak, and show a different
backtrace, e.g. GCC 16.2: https://godbolt.org/z/Ya351389h :
during IPA pass: analyzer
<source>: In function 'ice':
<source>:6:9: internal compiler error: Segmentation fault
    6 |         strtok(malloc(1), " ");
      |         ^~~~~~~~~~~~~~~~~~~~~~
0x20a13d8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x209a6cb internal_error(char const*, ...)
        ???:0
0x1298e80 ana::region_model::check_for_poison(ana::svalue const*, tree_node*,
ana::region const*, ana::region_model_context*) const
        ???:0
0x1299fb4 ana::region_model::scan_for_null_terminator_1(ana::region const*,
tree_node*, ana::svalue const**, ana::region_model_context*) const
        ???:0
0x127a5b7 ana::kf_strtok::strtok_call_info::update_model(ana::region_model*,
ana::exploded_edge const*, ana::region_model_context*) const
        ???:0
0x1281ee6 ana::gimple_stmt_op::execute_on_state(ana::operation_context&,
ana::program_state) const
        ???:0
0x1282586 ana::call_and_return_op::execute(ana::operation_context&) const
        ???:0
0x1266b40 ana::exploded_graph::process_node(ana::exploded_node*)
        ???:0
0x1267092 ana::exploded_graph::process_worklist()
        ???:0
0x126975f ana::impl_run_checkers(ana::logger*)
        ???:0
0x126a496 ana::run_checkers()
        ???:0

Reply via email to