public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "dimitri at ouroboros dot rocks" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/107582] - -Wanalyzer-use-of-uninitialized-value false positive using pthread_cond_timedwait Date: Tue, 08 Nov 2022 21:10:20 +0000 [thread overview] Message-ID: <bug-107582-4-g3AWDzsZZ9@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-107582-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107582 --- Comment #2 from dimitri at ouroboros dot rocks --- I've run into a weird false positive for the analyzer that seems to only occur with pthread_cond_timedwait. Compile the test file using gcc -c -fanalyzer test_if_else_pthread.c This will work fine. But if the while loop is enabled (which should be there in correct code): gcc -c -fanalyzer test_if_else_pthread_fp.c the following false-positive occurs: | 38 | while (z == 0 && ret != ETIMEDOUT) | | ^ | | | | | (4) following ‘true’ branch... | 39 | #endif | 40 | ret = pthread_cond_timedwait(&cond, &mutex, &now); | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | (5) ...to here | 41 | | 42 | if (ret != ETIMEDOUT) | | ~ | | | | | (6) following ‘false’ branch (when ‘ret == 110’)... | ‘main’: event 7 | | 45 | pthread_cleanup_pop(1); | | ^~~~~~~~~~~~~~~~~~~ | | | | | (7) ...to here | ‘main’: events 8-10 | | 47 | if (ret == ETIMEDOUT) | | ^ | | | | | (8) following ‘false’ branch (when ‘ret != 110’)... |...... | 50 | printf("x = %d\n", *x); | | ~~~~~~~~~~~~~~~~~~~~~~ | | | | | (9) ...to here | | (10) use of uninitialized value ‘x’ here Obviously, ret == ETIMEDOUT and ret != ETIMEDOUT can't both be false. I've tried writing a smaller example using mock functions that randomly return ETIMEDOUT instead of pthread_cond_timeout and that did not reproduce the false positive.
next prev parent reply other threads:[~2022-11-08 21:10 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-11-08 20:54 [Bug analyzer/107582] New: " dimitri at ouroboros dot rocks 2022-11-08 21:05 ` [Bug analyzer/107582] " dimitri at ouroboros dot rocks 2022-11-08 21:10 ` dimitri at ouroboros dot rocks [this message] 2022-11-08 21:43 ` dimitri at ouroboros dot rocks 2022-11-18 20:07 ` [Bug analyzer/107582] - -Wanalyzer-use-of-uninitialized-value false positive with while loop in pthread_cleanup_push dmalcolm at gcc dot gnu.org 2022-11-18 20:20 ` dmalcolm at gcc dot gnu.org 2022-11-19 0:40 ` cvs-commit at gcc dot gnu.org 2022-11-19 0:44 ` dmalcolm at gcc dot gnu.org 2022-11-19 0:46 ` dmalcolm at gcc dot gnu.org 2022-11-19 0:47 ` dmalcolm at gcc dot gnu.org 2022-11-19 21:29 ` dimitri at ouroboros dot rocks 2023-03-29 18:18 ` cvs-commit at gcc dot gnu.org 2023-03-29 19:26 ` dmalcolm at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-107582-4-g3AWDzsZZ9@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).