GithubHelp home page GithubHelp logo

Comments (6)

yagamy4680 avatar yagamy4680 commented on April 26, 2024

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.

oschwand avatar oschwand commented on April 26, 2024

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.

yagamy4680 avatar yagamy4680 commented on April 26, 2024

Thanks, it works.

from infer.

mcandre avatar mcandre commented on April 26, 2024

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.

jvillard avatar jvillard commented on April 26, 2024

The new way is easier: just run infer -- cmake ....

I forgot to comment again on this issue when I pushed 9f10b09 😶

from infer.

hongxuchen avatar hongxuchen commented on April 26, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.