llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
26.82k stars 10.99k forks source link

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

Open llvmbot opened 13 years ago

llvmbot commented 13 years ago
Bugzilla Link 8920
Version 2.8
OS Linux
Reporter LLVM Bugzilla Contributor
CC @tkremenek,@nelhage,@Lekensteyn

Extended Description

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.

llvmbot 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
llvmbot commented 8 years ago

I just hit this bug with 3.7.0.

Lekensteyn commented 9 years ago

Clang 3.5.1 is still affected by this issue.

llvmbot commented 13 years ago

ping!

llvmbot commented 13 years ago

ping! :)

llvmbot commented 13 years ago

Preprocessed version for the select(2) example

llvmbot commented 13 years ago

Example from select(2) manpage

tkremenek 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!

tkremenek commented 13 years ago

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

llvmbot commented 13 years ago

Ping!

llvmbot commented 13 years ago

assigned to @tkremenek