Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

clang-analyzer can't deal with FD_SET and FD_ZERO #9281

Open Quuxplusone opened 13 years ago

Quuxplusone commented 13 years ago
Bugzilla Link PR8920
Status NEW
Importance P normal
Reported by Andreas Schneider (asn@cryptomilk.org)
Reported on 2011-01-06 04:26:27 -0800
Last modified on 2021-04-30 09:58:00 -0700
Version 2.8
Hardware PC Linux
CC brian.p.walker2@boeing.com, fabian@ritter-vogt.de, kremenek@apple.com, llvm-bugs@lists.llvm.org, lukasz.czajczyk@gmail.com, nelhage@nelhage.com, peter@lekensteyn.nl
Fixed by commit(s)
Attachments select.c (694 bytes, text/plain)
select.e (59567 bytes, text/plain)
Blocks
Blocked by
See also
clang-analyzer can't really deal with FD_SET and FD_ZERO. I think the problem
is cause these macros are assembler code.

Code:

rc = select(maxfd, &localset, NULL, NULL, timeout);

...

FD_ZERO(&localset2);
for (f = 0; f < maxfd; f++) {
  if (FD_ISSET(f, readfds) && FD_ISSET(f, &localset)) {
    FD_SET(f, &localset2);
  }
}

http://test.libssh.org/clang-analyzer/

Result:

Within the expansion of the macro 'FD_SET':
 The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage.

Test code:

If you're looking for some test code see the EXAMPLE section in the select(2)
manpage.
Quuxplusone commented 13 years ago

Ping!

Quuxplusone commented 13 years ago

I haven't had a chance to look at this yet.

Quuxplusone commented 13 years ago
Can you provide:

(A) Self-contained source that exhibits the problem.
(B) A preprocessed version of that source (so I see the definitions on your
system).

Thanks!
Quuxplusone commented 13 years ago

Attached select.c (694 bytes, text/plain): Example from select(2) manpage

Quuxplusone commented 13 years ago

Attached select.e (59567 bytes, text/plain): Preprocessed version for the select(2) example

Quuxplusone commented 13 years ago

ping! :)

Quuxplusone commented 13 years ago

ping!

Quuxplusone commented 9 years ago

Clang 3.5.1 is still affected by this issue.

Quuxplusone commented 8 years ago

I just hit this bug with 3.7.0.

Quuxplusone commented 3 years ago
Bug still present as of :
$ clang --version
clang version 10.0.1 (Red Hat 10.0.1-1.module+el8.3.0+7459+90c24896)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Steps to reproduce:
1. Download select.c attached to this issue
2. scan-build clang select.c