{"$schema": "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",
 "version": "2.1.0",
 "runs": [{"tool": {"driver": {"name": "GNU C23",
                               "fullName": "GNU C23 (GCC) version 16.1.1 20260703 (Red Hat 16.1.1-4) (x86_64-redhat-linux)",
                               "version": "16.1.1 20260703 (Red Hat 16.1.1-4)",
                               "informationUri": "https://gcc.gnu.org/gcc-16/",
                               "rules": [{"id": "-Wanalyzer-fd-use-without-check",
                                          "helpUri": "https://gcc.gnu.org/onlinedocs/gcc-16.1.0/gcc/Static-Analyzer-Options.html#index-Wanalyzer-fd-use-without-check"}]}},
           "invocations": [{"arguments": ["/usr/libexec/gcc/x86_64-redhat-linux/16/cc1",
                                          "-quiet",
                                          "-I",
                                          "../src/include/",
                                          "-D",
                                          "_GNU_SOURCE",
                                          "-D",
                                          "__SANE_USERSPACE_TYPES__",
                                          "-D",
                                          "_LARGEFILE_SOURCE",
                                          "-D",
                                          "_FILE_OFFSET_BITS=64",
                                          "-D",
                                          "LIBURING_BUILD_TEST",
                                          "-include",
                                          "../config-host.h",
                                          "socket-rw-eagain.c",
                                          "-quiet",
                                          "-dumpbase",
                                          "socket-rw-eagain.c",
                                          "-dumpbase-ext",
                                          ".c",
                                          "-m64",
                                          "-mtune=generic",
                                          "-march=x86-64",
                                          "-mtls-dialect=gnu2",
                                          "-O2",
                                          "-Wno-unused-parameter",
                                          "-Wno-sign-compare",
                                          "-Wno-unknown-pragmas",
                                          "-flto=auto",
                                          "-ffat-lto-objects",
                                          "-fexceptions",
                                          "-fstack-protector-strong",
                                          "-fasynchronous-unwind-tables",
                                          "-fstack-clash-protection",
                                          "-fcf-protection=full",
                                          "-fno-omit-frame-pointer",
                                          "-fanalyzer",
                                          "-fdiagnostics-path-format=separate-events",
                                          "-fno-diagnostics-show-caret",
                                          "-fno-lto",
                                          "-fanalyzer-assume-nothrow",
                                          "-fdiagnostics-text-art-charset=none",
                                          "-fdiagnostics-set-output=sarif:file=/builddir/gcc-results/5064-pW8t.sarif",
                                          "-o",
                                          "/tmp/ccRdCIrh.s"],
                            "workingDirectory": {"uri": "/builddir/build/BUILD/liburing-2.13-build/liburing-2.13/test"},
                            "startTimeUtc": "2026-08-03T18:02:02Z",
                            "executionSuccessful": true,
                            "toolExecutionNotifications": [],
                            "endTimeUtc": "2026-08-03T18:02:03Z"}],
           "originalUriBaseIds": {"PWD": {"uri": "file:///builddir/build/BUILD/liburing-2.13-build/liburing-2.13/test/"}},
           "artifacts": [{"location": {"uri": "socket-rw-eagain.c",
                                       "uriBaseId": "PWD"},
                          "sourceLanguage": "c",
                          "contents": {"text": "/* SPDX-License-Identifier: MIT */\n/*\n * Check that a readv on a nonblocking socket queued before a writev doesn't\n * wait for data to arrive.\n */\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdint.h>\n#include <assert.h>\n\n#include <errno.h>\n#include <fcntl.h>\n#include <unistd.h>\n#include <sys/socket.h>\n#include <sys/un.h>\n#include <netinet/tcp.h>\n#include <netinet/in.h>\n#include <arpa/inet.h>\n\n#include \"liburing.h\"\n#include \"helpers.h\"\n\nint main(int argc, char *argv[])\n{\n\tint p_fd[2], ret;\n\tint32_t recv_s0;\n\tint32_t val = 1;\n\tstruct sockaddr_in addr;\n\tstruct iovec iov_r[1], iov_w[1];\n\n\tif (argc > 1)\n\t\treturn 0;\n\n\tsrand(getpid());\n\n\trecv_s0 = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);\n\n\tret = setsockopt(recv_s0, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val));\n\tassert(ret != -1);\n\tret = setsockopt(recv_s0, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));\n\tassert(ret != -1);\n\n\taddr.sin_family = AF_INET;\n\taddr.sin_addr.s_addr = inet_addr(\"127.0.0.1\");\n\tret = t_bind_ephemeral_port(recv_s0, &addr);\n\tassert(!ret);\n\tret = listen(recv_s0, 128);\n\tassert(ret != -1);\n\n\tp_fd[1] = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);\n\n\tval = 1;\n\tret = setsockopt(p_fd[1], IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));\n\tassert(ret != -1);\n\n\tt_set_nonblock(p_fd[1]);\n\n\tret = connect(p_fd[1], (struct sockaddr*)&addr, sizeof(addr));\n\tassert(ret == -1);\n\n\tp_fd[0] = accept(recv_s0, NULL, NULL);\n\tassert(p_fd[0] != -1);\n\n\tt_set_nonblock(p_fd[0]);\n\n\twhile (1) {\n\t\tint32_t code;\n\t\tsocklen_t code_len = sizeof(code);\n\n\t\tret = getsockopt(p_fd[1], SOL_SOCKET, SO_ERROR, &code, &code_len);\n\t\tassert(ret != -1);\n\n\t\tif (!code)\n\t\t\tbreak;\n\t}\n\n\tstruct io_uring m_io_uring;\n\tstruct io_uring_params p = { };\n\n\tret = io_uring_queue_init_params(32, &m_io_uring, &p);\n\tassert(ret >= 0);\n\n\tif (p.features & IORING_FEAT_FAST_POLL)\n\t\treturn 0;\n\n\tchar recv_buff[128];\n\tchar send_buff[128];\n\n\t{\n\t\tiov_r[0].iov_base = recv_buff;\n\t\tiov_r[0].iov_len = sizeof(recv_buff);\n\n\t\tstruct io_uring_sqe* sqe = io_uring_get_sqe(&m_io_uring);\n\t\tassert(sqe != NULL);\n\n\t\tio_uring_prep_readv(sqe, p_fd[0], iov_r, 1, 0);\n\t\tsqe->user_data = 1;\n\t}\n\n\t{\n\t\tiov_w[0].iov_base = send_buff;\n\t\tiov_w[0].iov_len = sizeof(send_buff);\n\n\t\tstruct io_uring_sqe* sqe = io_uring_get_sqe(&m_io_uring);\n\t\tassert(sqe != NULL);\n\n\t\tio_uring_prep_writev(sqe, p_fd[1], iov_w, 1, 0);\n\t\tsqe->user_data = 2;\n\t}\n\n\tret = io_uring_submit_and_wait(&m_io_uring, 2);\n\tassert(ret != -1);\n\n\tstruct io_uring_cqe* cqe;\n\tuint32_t head;\n\tuint32_t count = 0;\n\n\twhile (count != 2) {\n\t\tio_uring_for_each_cqe(&m_io_uring, head, cqe) {\n\t\t\tif (cqe->user_data == 2 && cqe->res != 128) {\n\t\t\t\tfprintf(stderr, \"write=%d\\n\", cqe->res);\n\t\t\t\tgoto err;\n\t\t\t} else if (cqe->user_data == 1 && cqe->res != -EAGAIN) {\n\t\t\t\tfprintf(stderr, \"read=%d\\n\", cqe->res);\n\t\t\t\tgoto err;\n\t\t\t}\n\t\t\tcount++;\n\t\t}\n\n\t\tassert(count <= 2);\n\t\tio_uring_cq_advance(&m_io_uring, count);\n\t}\n\n\tio_uring_queue_exit(&m_io_uring);\n\treturn 0;\nerr:\n\tio_uring_queue_exit(&m_io_uring);\n\treturn 1;\n}\n"},
                          "roles": ["analysisTarget",
                                    "tracedFile"]}],
           "results": [{"ruleId": "-Wanalyzer-fd-use-without-check",
                        "properties": {"gcc/analyzer/saved_diagnostic/sm": "file-descriptor",
                                       "gcc/analyzer/saved_diagnostic/ploc": {"enode": 39},
                                       "gcc/analyzer/saved_diagnostic/sval": "UNMERGEABLE((int32_t)-1)",
                                       "gcc/analyzer/saved_diagnostic/state": "fd-invalid",
                                       "gcc/analyzer/saved_diagnostic/idx": 0,
                                       "gcc/analyzer/saved_diagnostic/duplicates": [{"properties": {"gcc/analyzer/saved_diagnostic/sm": "file-descriptor",
                                                                                                    "gcc/analyzer/saved_diagnostic/ploc": {"enode": 39},
                                                                                                    "gcc/analyzer/saved_diagnostic/sval": "UNMERGEABLE((int32_t)-1)",
                                                                                                    "gcc/analyzer/saved_diagnostic/state": "fd-invalid",
                                                                                                    "gcc/analyzer/saved_diagnostic/idx": 1,
                                                                                                    "gcc/analyzer/pending_diagnostic/kind": "fd_use_without_check"}}],
                                       "gcc/analyzer/pending_diagnostic/kind": "fd_use_without_check"},
                        "level": "warning",
                        "message": {"text": "‘listen’ on possibly invalid file descriptor ‘recv_s0’"},
                        "locations": [{"physicalLocation": {"artifactLocation": {"uri": "socket-rw-eagain.c",
                                                                                 "uriBaseId": "PWD"},
                                                            "region": {"startLine": 47,
                                                                       "startColumn": 15,
                                                                       "endColumn": 35},
                                                            "contextRegion": {"startLine": 47,
                                                                              "snippet": {"text": "\tret = listen(recv_s0, 128);\n"}}},
                                       "logicalLocations": [{"index": 0,
                                                             "fullyQualifiedName": "main"}]}],
                        "codeFlows": [{"threadFlows": [{"id": "main",
                                                        "locations": [{"properties": {"gcc/analyzer/checker_event/emission_id": "(1)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 2,
                                                                                                                                 "dst_id": 4}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "socket-rw-eagain.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 31,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 31,
                                                                                                                           "snippet": {"text": "\tif (argc > 1)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "main"}],
                                                                                    "message": {"text": "following ‘false’ branch (when ‘argc <= 1’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 1},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(2)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 2,
                                                                                                                                 "dst_id": 4}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "socket-rw-eagain.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 34,
                                                                                                                    "startColumn": 15,
                                                                                                                    "endColumn": 23},
                                                                                                         "contextRegion": {"startLine": 34,
                                                                                                                           "snippet": {"text": "\tsrand(getpid());\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "main"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 2},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(3)",
                                                                                      "gcc/analyzer/checker_event/kind": "custom"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "socket-rw-eagain.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 36,
                                                                                                                    "startColumn": 19,
                                                                                                                    "endColumn": 75},
                                                                                                         "contextRegion": {"startLine": 36,
                                                                                                                           "snippet": {"text": "\trecv_s0 = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "main"}],
                                                                                    "message": {"text": "when ‘socket’ fails"}},
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 3},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(4)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 9,
                                                                                                                                 "dst_id": 12}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "socket-rw-eagain.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 39,
                                                                                                                    "startColumn": 9,
                                                                                                                    "endColumn": 10},
                                                                                                         "contextRegion": {"startLine": 39,
                                                                                                                           "snippet": {"text": "\tassert(ret != -1);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "main"}],
                                                                                    "message": {"text": "following ‘true’ branch (when ‘ret != -1’)..."},
                                                                                    "id": 0,
                                                                                    "relationships": [{"target": 1,
                                                                                                       "kinds": ["isIncludedBy"]}]},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 4},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(5)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 9,
                                                                                                                                 "dst_id": 12}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "socket-rw-eagain.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 40,
                                                                                                                    "startColumn": 15,
                                                                                                                    "endColumn": 79},
                                                                                                         "contextRegion": {"startLine": 40,
                                                                                                                           "snippet": {"text": "\tret = setsockopt(recv_s0, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "main"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 5},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(6)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 13,
                                                                                                                                 "dst_id": 16}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "socket-rw-eagain.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 41,
                                                                                                                    "startColumn": 9,
                                                                                                                    "endColumn": 10},
                                                                                                         "contextRegion": {"startLine": 41,
                                                                                                                           "snippet": {"text": "\tassert(ret != -1);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "main"}],
                                                                                    "message": {"text": "following ‘true’ branch (when ‘ret != -1’)..."},
                                                                                    "id": 2,
                                                                                    "relationships": [{"target": 1,
                                                                                                       "kinds": ["isIncludedBy"]}]},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 6},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(7)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 13,
                                                                                                                                 "dst_id": 16}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "socket-rw-eagain.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 43,
                                                                                                                    "startColumn": 9,
                                                                                                                    "endColumn": 28},
                                                                                                         "contextRegion": {"startLine": 43,
                                                                                                                           "snippet": {"text": "\taddr.sin_family = AF_INET;\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "main"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 7},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(8)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 20,
                                                                                                                                 "dst_id": 23}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "socket-rw-eagain.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 46,
                                                                                                                    "startColumn": 9,
                                                                                                                    "endColumn": 10},
                                                                                                         "contextRegion": {"startLine": 46,
                                                                                                                           "snippet": {"text": "\tassert(!ret);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "main"}],
                                                                                    "message": {"text": "following ‘true’ branch..."},
                                                                                    "id": 3,
                                                                                    "relationships": [{"target": 1,
                                                                                                       "kinds": ["isIncludedBy"]}]},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 8},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(9)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 20,
                                                                                                                                 "dst_id": 23}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "socket-rw-eagain.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 47,
                                                                                                                    "startColumn": 15,
                                                                                                                    "endColumn": 35},
                                                                                                         "contextRegion": {"startLine": 47,
                                                                                                                           "snippet": {"text": "\tret = listen(recv_s0, 128);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "main"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 9},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(10)",
                                                                                      "gcc/analyzer/checker_event/kind": "warning"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "socket-rw-eagain.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 47,
                                                                                                                    "startColumn": 15,
                                                                                                                    "endColumn": 35},
                                                                                                         "contextRegion": {"startLine": 47,
                                                                                                                           "snippet": {"text": "\tret = listen(recv_s0, 128);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "main"}],
                                                                                    "message": {"text": "‘recv_s0’ could be invalid"}},
                                                                       "kinds": ["danger"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 10}]}]}],
                        "relatedLocations": [{"physicalLocation": {"artifactLocation": {"uri": "socket-rw-eagain.c",
                                                                                        "uriBaseId": "PWD"},
                                                                   "region": {"startLine": 9},
                                                                   "contextRegion": {"startLine": 9,
                                                                                     "snippet": {"text": "#include <assert.h>\n"}}},
                                              "relationships": [{"target": 0,
                                                                 "kinds": ["includes"]},
                                                                {"target": 2,
                                                                 "kinds": ["includes"]},
                                                                {"target": 3,
                                                                 "kinds": ["includes"]}],
                                              "id": 1}]}],
           "logicalLocations": [{"name": "main",
                                 "fullyQualifiedName": "main",
                                 "decoratedName": "main",
                                 "kind": "function",
                                 "index": 0}]}]}
