public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/107366] New: -fanalyzer with -fdiagnostics-format=sarif-file or sarif-stderr
@ 2022-10-23 12:15 rainer.keller@hs-esslingen.de
  2022-10-24  7:38 ` [Bug analyzer/107366] " marxin at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: rainer.keller@hs-esslingen.de @ 2022-10-23 12:15 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107366
           Summary: -fanalyzer with -fdiagnostics-format=sarif-file or
                    sarif-stderr
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rainer.keller@hs-esslingen.de
  Target Milestone: ---

Created attachment 53760
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53760&action=edit
Compilation of -freport-bug

Compiling hwloc-2.8.0 with -fanalyzer and either
-fdiagnostics-format=sarif-file or -fdiagnostics-format=sarif-stderr produces:

during IPA pass: analyzer
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
See <https://gcc.gnu.org/bugs/> for instructions.

Unfortunately I wasn't able to produce a MWE.
Steps to reproduce:
   wget https://download.open-mpi.org/release/hwloc/v2.8/hwloc-2.8.0.tar.bz2
   tar xf hwloc-2.8.0.tar.bz2 && cd hwloc-2.8.0
   mkdir BUILD && cd $_
   ../configure --prefix=$PWD/usr
   make CFLAGS="-fanalyzer -fdiagnostics-format=sarif-stderr"
fails in hwloc/diff.c

Using -fdiagnostics-format=json-stderr and -file works.

The above does not seem to be related to https://gcc.gnu.org/PR106703

Attached is the -freport-bug of same file.
Thanks

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug analyzer/107366] -fanalyzer with -fdiagnostics-format=sarif-file or sarif-stderr
  2022-10-23 12:15 [Bug c/107366] New: -fanalyzer with -fdiagnostics-format=sarif-file or sarif-stderr rainer.keller@hs-esslingen.de
@ 2022-10-24  7:38 ` marxin at gcc dot gnu.org
  2022-10-24  7:46 ` marxin at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-10-24  7:38 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
                 CC|                            |marxin at gcc dot gnu.org
   Last reconfirmed|                            |2022-10-24
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Reduced test-case:

$ cat pr107366.c
typedef enum {
  HWLOC_TOPOLOGY_DIFF_OBJ_ATTR_INFO
} hwloc_topology_diff_obj_attr_type_t;
enum { HWLOC_TOPOLOGY_DIFF_OBJ_ATTR } hwloc_apply_diff_one_diff_0_0;

void
hwloc_apply_diff_one() {
  switch (hwloc_apply_diff_one_diff_0_0)
  case HWLOC_TOPOLOGY_DIFF_OBJ_ATTR: {
    hwloc_topology_diff_obj_attr_type_t obj_attr_2_0_0;
    switch (obj_attr_2_0_0)
    case HWLOC_TOPOLOGY_DIFF_OBJ_ATTR_INFO: {
      unsigned ii = 0;
    }
  }
}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug analyzer/107366] -fanalyzer with -fdiagnostics-format=sarif-file or sarif-stderr
  2022-10-23 12:15 [Bug c/107366] New: -fanalyzer with -fdiagnostics-format=sarif-file or sarif-stderr rainer.keller@hs-esslingen.de
  2022-10-24  7:38 ` [Bug analyzer/107366] " marxin at gcc dot gnu.org
@ 2022-10-24  7:46 ` marxin at gcc dot gnu.org
  2022-10-24  7:47 ` marxin at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-10-24  7:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Happens for the following location:

(gdb) p /x loc
$7 = 0x80000008

when I expand it:

(gdb) p x
$8 = {
  file = 0x0,
  line = 0,
  column = 0,
  data = 0x7ffff7769480,
  sysp = false
}

it likely corresponds to (5):

gcc -Wfatal-errors pr107366.c -c -fanalyzer
In function ‘hwloc_apply_diff_one’:
cc1: warning: use of uninitialized value ‘obj_attr_2_0_0’ [CWE-457]
[-Wanalyzer-use-of-uninitialized-value]
  ‘hwloc_apply_diff_one’: events 1-4
    |
    |pr107366.c:10:41:
    |    8 |   switch (hwloc_apply_diff_one_diff_0_0)
    |      |   ~~~~~~                                 
    |      |   |
    |      |   (3) following ‘true’ branch...
    |    9 |   case HWLOC_TOPOLOGY_DIFF_OBJ_ATTR: {
    |      |   ~~~~                                   
    |      |   |
    |      |   (4) ...to here
    |   10 |     hwloc_topology_diff_obj_attr_type_t obj_attr_2_0_0;
    |      |                                         ^~~~~~~~~~~~~~
    |      |                                         |
    |      |                                         (1) region created on
stack here
    |      |                                         (2) capacity: 4 bytes
    |
  ‘hwloc_apply_diff_one’: event 5
    |
    |cc1:
    | (5): use of uninitialized value ‘obj_attr_2_0_0’ here
    |

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug analyzer/107366] -fanalyzer with -fdiagnostics-format=sarif-file or sarif-stderr
  2022-10-23 12:15 [Bug c/107366] New: -fanalyzer with -fdiagnostics-format=sarif-file or sarif-stderr rainer.keller@hs-esslingen.de
  2022-10-24  7:38 ` [Bug analyzer/107366] " marxin at gcc dot gnu.org
  2022-10-24  7:46 ` marxin at gcc dot gnu.org
@ 2022-10-24  7:47 ` marxin at gcc dot gnu.org
  2022-10-24 15:13 ` [Bug analyzer/107366] ICE with " dmalcolm at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-10-24  7:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
Potential fix:

diff --git a/gcc/diagnostic-format-sarif.cc b/gcc/diagnostic-format-sarif.cc
index fc28d160c38..7110db4edd6 100644
--- a/gcc/diagnostic-format-sarif.cc
+++ b/gcc/diagnostic-format-sarif.cc
@@ -595,7 +595,7 @@ sarif_builder::make_location_object (const diagnostic_event
&event)
 json::object *
 sarif_builder::maybe_make_physical_location_object (location_t loc)
 {
-  if (loc <= BUILTINS_LOCATION)
+  if (loc <= BUILTINS_LOCATION || LOCATION_FILE (loc) == NULL)
     return NULL;

   json::object *phys_loc_obj = new json::object ();

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug analyzer/107366] ICE with -fanalyzer with -fdiagnostics-format=sarif-file or sarif-stderr
  2022-10-23 12:15 [Bug c/107366] New: -fanalyzer with -fdiagnostics-format=sarif-file or sarif-stderr rainer.keller@hs-esslingen.de
                   ` (2 preceding siblings ...)
  2022-10-24  7:47 ` marxin at gcc dot gnu.org
@ 2022-10-24 15:13 ` dmalcolm at gcc dot gnu.org
  2022-10-24 20:49 ` cvs-commit at gcc dot gnu.org
  2022-10-24 21:02 ` dmalcolm at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2022-10-24 15:13 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED

--- Comment #4 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Rainer: thanks for filing this bug.

Martin: thanks for reducing it and identifying the fix.  I believe it's
correct, and am bootstrapping a patch containing it.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug analyzer/107366] ICE with -fanalyzer with -fdiagnostics-format=sarif-file or sarif-stderr
  2022-10-23 12:15 [Bug c/107366] New: -fanalyzer with -fdiagnostics-format=sarif-file or sarif-stderr rainer.keller@hs-esslingen.de
                   ` (3 preceding siblings ...)
  2022-10-24 15:13 ` [Bug analyzer/107366] ICE with " dmalcolm at gcc dot gnu.org
@ 2022-10-24 20:49 ` cvs-commit at gcc dot gnu.org
  2022-10-24 21:02 ` dmalcolm at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-10-24 20:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:

https://gcc.gnu.org/g:2e8a0553918adc919f98ac5c0224fc6ce1fef68d

commit r13-3469-g2e8a0553918adc919f98ac5c0224fc6ce1fef68d
Author: Martin Liska <mliska@suse.cz>
Date:   Mon Oct 24 16:40:00 2022 -0400

    diagnostics: fix ICE in sarif output with NULL filename [PR107366]

    gcc/ChangeLog:
            PR analyzer/107366
            * diagnostic-format-sarif.cc
            (sarif_builder::maybe_make_physical_location_object): Gracefully
            reject locations with NULL filename.

    gcc/testsuite/ChangeLog:
            PR analyzer/107366
            * gcc.dg/analyzer/sarif-pr107366.c: New test.

    Signed-off-by: David Malcolm <dmalcolm@redhat.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug analyzer/107366] ICE with -fanalyzer with -fdiagnostics-format=sarif-file or sarif-stderr
  2022-10-23 12:15 [Bug c/107366] New: -fanalyzer with -fdiagnostics-format=sarif-file or sarif-stderr rainer.keller@hs-esslingen.de
                   ` (4 preceding siblings ...)
  2022-10-24 20:49 ` cvs-commit at gcc dot gnu.org
@ 2022-10-24 21:02 ` dmalcolm at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2022-10-24 21:02 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Should be fixed by the above patch.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-10-24 21:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-23 12:15 [Bug c/107366] New: -fanalyzer with -fdiagnostics-format=sarif-file or sarif-stderr rainer.keller@hs-esslingen.de
2022-10-24  7:38 ` [Bug analyzer/107366] " marxin at gcc dot gnu.org
2022-10-24  7:46 ` marxin at gcc dot gnu.org
2022-10-24  7:47 ` marxin at gcc dot gnu.org
2022-10-24 15:13 ` [Bug analyzer/107366] ICE with " dmalcolm at gcc dot gnu.org
2022-10-24 20:49 ` cvs-commit at gcc dot gnu.org
2022-10-24 21:02 ` dmalcolm at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).