public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug driver/110522] New: `-fdiagnostics-format=sarif-file`: file name conflicts / races
@ 2023-07-02 14:41 lebedev.ri at gmail dot com
  2023-07-03 14:02 ` [Bug driver/110522] " lebedev.ri at gmail dot com
  2023-07-18  0:17 ` lebedev.ri at gmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: lebedev.ri at gmail dot com @ 2023-07-02 14:41 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110522
           Summary: `-fdiagnostics-format=sarif-file`: file name conflicts
                    / races
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: driver
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lebedev.ri at gmail dot com
  Target Milestone: ---

The sarif-file is stored into PWD of the compiler invocation.
Worse yet, it uses only a basename of the target object file,
but with a `.c.sarif` suffix.

What happens when the same object file is created multiple times,
in different directories? The results will be overwritten.

And in some cases, you may even lose the whole log of the failed compilation,
(especially because the moment you specify `-fdiagnostics-format=sarif-file`,
there's *NOTHING* in stderr, and you can't even specify `-fdiagnostics-format=`
twice)
if it will later be overwritten by the successful compilation
of some different TU that happened to produce object file with the same base
name.

I'm not sure how this was not pointed out during the initial implementation,
this seems problematic.

```
$ cat Makefile 
bad:
        gcc-13 -fdiagnostics-format=sarif-file -c common/a.c -o common/file.o

good:
        gcc-13 -fdiagnostics-format=sarif-file -c b.c -o file.o

all: good bad

clean:
        rm common/file.o file.o
$ cat common/a.c 
bad
$ cat b.c 
// good
$ VERBOSE=1 make bad good
gcc-13 -fdiagnostics-format=sarif-file -c common/a.c -o common/file.o
make: *** [Makefile:2: bad] Error 1
$ ls
Makefile  b.c  common  file.c.sarif  file.o
$ cat file.c.sarif 
{"$schema":
"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
"version": "2.1.0", "runs": [{"tool": {"driver": {"name": "GNU C17",
"fullName": "GNU C17 (Debian 13.1.0-7) version 13.1.0 (x86_64-linux-gnu)",
"version": "13.1.0", "informationUri": "https://gcc.gnu.org/gcc-13/", "rules":
[]}}, "invocations": [{"executionSuccessful": true,
"toolExecutionNotifications": []}], "originalUriBaseIds": {"PWD": {"uri":
"file:///tmp/test/"}}, "artifacts": [{"location": {"uri": "common/a.c",
"uriBaseId": "PWD"}, "contents": {"text": "bad\n"}, "sourceLanguage": "c"}],
"results": [{"ruleId": "error", "level": "error", "message": {"text": "expected
‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ at end of input"}, "locations":
[{"physicalLocation": {"artifactLocation": {"uri": "common/a.c", "uriBaseId":
"PWD"}, "region": {"startLine": 1, "startColumn": 1, "endColumn": 4},
"contextRegion": {"startLine": 1, "snippet": {"text": "bad\n"}}}}]}]}]}
$ VERBOSE=1 make -k bad good
gcc-13 -fdiagnostics-format=sarif-file -c common/a.c -o common/file.o
make: *** [Makefile:2: bad] Error 1
gcc-13 -fdiagnostics-format=sarif-file -c b.c -o file.o
$ cat file.c.sarif 
{"$schema":
"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
"version": "2.1.0", "runs": [{"tool": {"driver": {"name": "GNU C17",
"fullName": "GNU C17 (Debian 13.1.0-7) version 13.1.0 (x86_64-linux-gnu)",
"version": "13.1.0", "informationUri": "https://gcc.gnu.org/gcc-13/", "rules":
[]}}, "invocations": [{"executionSuccessful": true,
"toolExecutionNotifications": []}], "artifacts": [], "results": []}]}
```

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

* [Bug driver/110522] `-fdiagnostics-format=sarif-file`: file name conflicts / races
  2023-07-02 14:41 [Bug driver/110522] New: `-fdiagnostics-format=sarif-file`: file name conflicts / races lebedev.ri at gmail dot com
@ 2023-07-03 14:02 ` lebedev.ri at gmail dot com
  2023-07-18  0:17 ` lebedev.ri at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: lebedev.ri at gmail dot com @ 2023-07-03 14:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Roman Lebedev <lebedev.ri at gmail dot com> ---
To spell it out explicitly, not storing the resulting `.sarif`
next to the produced object file itself, like it's done in (all?)
other cases, very much looks like a not-a-feature,
basically making the feature to be borderline unusable in general.

There can be some edge-cases (`-o /dev/null`?),
but they shouldn't dictate how normal cases are handled.

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

* [Bug driver/110522] `-fdiagnostics-format=sarif-file`: file name conflicts / races
  2023-07-02 14:41 [Bug driver/110522] New: `-fdiagnostics-format=sarif-file`: file name conflicts / races lebedev.ri at gmail dot com
  2023-07-03 14:02 ` [Bug driver/110522] " lebedev.ri at gmail dot com
@ 2023-07-18  0:17 ` lebedev.ri at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: lebedev.ri at gmail dot com @ 2023-07-18  0:17 UTC (permalink / raw)
  To: gcc-bugs

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

Roman Lebedev <lebedev.ri at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmalcolm at redhat dot com,
                   |                            |dseketel at redhat dot com,
                   |                            |jwakely at redhat dot com

--- Comment #2 from Roman Lebedev <lebedev.ri at gmail dot com> ---
Would it please be possible to get an acknowledgement/rejection on this,
please?
It seems like a rather unexpected usability roadblock.

Also, Dodji Seketeli's email from MAINTAINERS is unknown to bugzilla.

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

end of thread, other threads:[~2023-07-18  0:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-02 14:41 [Bug driver/110522] New: `-fdiagnostics-format=sarif-file`: file name conflicts / races lebedev.ri at gmail dot com
2023-07-03 14:02 ` [Bug driver/110522] " lebedev.ri at gmail dot com
2023-07-18  0:17 ` lebedev.ri at gmail dot com

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).