Comments (6)
Here is a simpler way to reproduce this issue:
main.c
#include <stdio.h>
int main()
{
int *s = NULL;
*s = 42;
printf("hello world. \n");
}
CMakeLists.txt
cmake_minimum_required (VERSION 2.6)
project(ex1)
add_executable(ex1 main.c)
Using makefile generated by CMake:
# cmake .
# make clean
# infer -- make
Scanning dependencies of target ex1
[100%] Building C object CMakeFiles/ex1.dir/main.c.o
Linking C executable ex1
[100%] Built target ex1
Starting analysis (Infer version v0.1.0)
Analysis done
0 file analyzed
Compile main.c
with gcc and infer:
# infer -- gcc ./main.c
Starting analysis (Infer version v0.1.0)
Analysis done
1 file analyzed
main.c:6: error: NULL_DEREFERENCE
pointer s last assigned on line 5 could be null and is dereferenced at line 6, column 5
from infer.
The problem is that cmake generates a Makefile which runs directly /usr/bin/cc, so infer cannot replace it by its own wrapper (since it relies on ugly $PATH tricks).
It works if you explicitly change the CC variable in order to use the infer wrapper:
CC=/path/to/infer/infer/lib/capture/clang cmake .
infer -- make
Be careful that CC can be set only one time, so you will need to clean all the cmake cache files or to use a fresh out-of-sources build directory.
from infer.
Thanks, it works.
from infer.
infer 0.8.0 from Homebrew doesn't appear to have a path like .../lib/capture/clang
. Is there a similar command for running infer 0.8.0 against cmake-generated Makefiles?
from infer.
The new way is easier: just run infer -- cmake ...
.
I forgot to comment again on this issue when I pushed 9f10b09 😶
from infer.
@jvillard I tried using infer -- cmake .
for exiv2, but it seems that the wrapper fails to detect some dependency library:
CMake Error at /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version "1.2.11")
Call Stack (most recent call first):
/usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.10/Modules/FindZLIB.cmake:112 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
cmake/findDependencies.cmake:22 (find_package)
CMakeLists.txt:63 (include)
While the library can be correctly found by cmake .
even when I export CC=/path/to/infer/clang/wrapper
:
-- Found Threads: TRUE
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11")
-- Found EXPAT: /usr/lib/x86_64-linux-gnu/libexpat.so (found version "2.2.5")
-- Found Intl: /usr/include
-- Performing Test Iconv_IS_BUILT_IN
-- Performing Test Iconv_IS_BUILT_IN - Success
-- Found Iconv: /usr/lib/x86_64-linux-gnu/libc.so
-- ICONV_INCLUDE_DIR :
-- ICONV_LIBRARIES : /usr/lib/x86_64-linux-gnu/libc.so
On the other hand, export CC=/path/to/infer/clang/wrapper
followed by infer -- make
emits similar messages like There was nothing to analyze.
.
May I know the possible reasons?
from infer.
Related Issues (20)
- [java] DEADLOCK: False Negative in Infer analysis results after converting anonymous classes to lambda expressions HOT 1
- [java] STARVATION: False Negative in Infer analysis results after converting anonymous classes to lambda expressions HOT 1
- False positive of Infer/Pulse when `std::unique_ptr` is used with no throw `new` HOT 2
- how to use --custom-symbols?
- How to check custom malloc and free functions for memory leak?
- can infer find out all suspecious bugs? HOT 2
- java: Infer injects outdated, buggy maven-compiler-plugin version 3.8.0
- False positive memory leak on loop HOT 4
- Dockerfile: US-ASCII locale causes crash on UTF-8 input
- How to add extra nullability condition to NULL_DEREFERENCE checking
- Is Adding a C++ Infer Port to the VSCode Plugin on the Roadmap? HOT 3
- [java] A false negative about the rule NULL_DEREFERENCE
- [java] A false positive about the rule THREAD_SAFETY_VIOLATION
- `--biabduction-unsafe-malloc` doesn't assume that `calloc()` and `realloc()` never return null HOT 1
- Error building the `Resource Leak analysis` lab in docker
- False positive Uninitialized Value in C code
- Need help when using infer run or capture during maven compilation HOT 1
- Query on --changed-files-index option HOT 3
- Meta leak HOT 1
- Infer - clang plugin OCaml - Issue HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from infer.