llvm / llvm-project

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

False positive in checker: Function call argument is an uninitialized value #16774

Closed llvmbot closed 11 years ago

llvmbot commented 11 years ago
Bugzilla Link 16400
Resolution WONTFIX
Resolved on Jul 01, 2013 20:18
Version trunk
OS Linux
Attachments wireshark/tshark.c Line: 2721
Reporter LLVM Bugzilla Contributor
CC @belkadan

Extended Description

Tested with clang r184521 on Ubuntu 13.04, x86.

Clang claims that one of the arguments of a function call is uninitialized.

However, it only reaches that code path after:

"Assuming 'do_dissection' is 0", and "Assuming 'do_dissection' is not equal to 0",

with no usage or access of do_dissection in between.

do_dissection is a "static gboolean", and if you examine the docs:

( http://svn.abisource.com/wv/tags/release-version-0-7-11/glib-wv/glib.h )

typedef int gint; typedef gint gboolean;

So to my understanding, a gboolean is effectively an int.

The attached file is tshark.c from wireshark r50104.

belkadan commented 11 years ago

The analyzer is conservative about global variables, even static global variables, and assumes that any function calls it sees could change the variable. IPA mitigates this a bit, and there are techniques we could add to figure out that a particular function does /not/ touch a global, but in the general case it's an unsolvable problem. I don't think we're going to be able to fix this any time soon.

Workaround: cache the results of the check in a local variable.

llvmbot commented 11 years ago

Preprocessed output of tshark.c The preprocessed version of tshark.c

Created by appending -save-temps to the CFLAGS in the makefile.

belkadan commented 11 years ago

Can you please attach a preprocessed version of tshark.c, so we can try to reproduce the problem under roughly the same configuration?

llvmbot commented 11 years ago

assigned to @tkremenek