facebook / infer

A static analyzer for Java, C, C++, and Objective-C
http://fbinfer.com/
MIT License
14.89k stars 2.01k forks source link

Can't find C++ example #1683

Open insublee opened 1 year ago

insublee commented 1 year ago

0. summary

Hi, https://fbinfer.com/ states that Infer supports Cpp. But https://fbinfer.com/docs/hello-world doesn't show any Cpp examples. So, I tried running it in google collaboration, but I don't know what the problem is. Any help would be appreciated.

1. env

google colab) Linux-5.10.133+-x86_64-with-Ubuntu-18.04-bionic Ubuntu 18.04.6 LTS Python 3.7.14

2. code

'!sudo apt-get update && sudo apt-get upgrade && \ VERSION=1.0.0; \ curl -sSL https://github.com/facebook/infer/releases/download/v$VERSION/infer-linux64-v$VERSION.tar.xz" | sudo tar -C /opt -xJ && \ sudo ln -s "/opt/infer-linux64-v$VERSION/bin/infer" /usr/local/bin/infer

code="""#include

include

class Foo { public: void myshell() { execl(getenv("foo"), getenv("foo")); }

}; int main(int argc, char argv[]) { Foo f = new Foo(); f->myshell(); execl(getenv("foo"), getenv("foo")); } """

with open('test.cpp', 'w') as f: f.write(code)

!infer run -- g++ -c test.cpp`

3. error mesage

Capturing in make/cc mode... error: unable to load plugin '/opt/infer-linux64-v1.0.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib': '/usr/lib/x86_64-linux-gnu/libstdc++.so.6: versionGLIBCXX_3.4.26' not found (required by /opt/infer-linux64-v1.0.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib)' Uncaught Internal Error: (Bi_inbuf.End_of_input) Error backtrace: Raised at Bi_inbuf.read_char in file "src/bi_inbuf.ml", line 49, characters 6-24 Called from Bi_io.read_tag in file "src/bi_io.ml" (inlined), line 508, characters 12-35 Called from ATDGeneratedClang_ast_b.read_decl in file "src/atd/clang_ast_b.ml", line 38422, characters 7-24 Called from Atdgen_runtimeUtil.Biniou.from_channel in file "atdgen-runtime/src/util.ml" (inlined), line 30, characters 4-11 Called from ClangFrontendCapture.validate_decl_from_channel in file "src/clang/Capture.ml", line 23, characters 2-113 Re-raised at IStdlib__IExn.reraise_if in file "src/istd/IExn.ml" (inlined), line 18, characters 15-63 Called from ClangFrontendCapture.run_and_validate_clang_frontend in file "src/clang/Capture.ml", line 108, characters 4-60 Called from IBaseUtils.with_process_in.f in file "src/base/Utils.ml" (inlined), line 263, characters 13-22 Called from IBaseUtils.do_finally_swallow_timeout in file "src/base/Utils.ml" (inlined), line 183, characters 8-12 Called from IBaseUtils.with_process_in in file "src/base/Utils.ml", line 268, characters 2-40 Re-raised at IStdlibIExn.reraise_after in file "src/istd/IExn.ml" (inlined), line 13, characters 2-50 Called from IBaseUtils.do_finally_swallow_timeout in file "src/base/Utils.ml" (inlined), line 185, characters 6-141 Called from IBaseUtils.with_process_in in file "src/base/Utils.ml", line 268, characters 2-40 Called from ClangFrontendCapture.run_clang in file "src/clang/Capture.ml" (inlined), line 119, characters 8-78 Called from ClangFrontendCapture.run_plugin_and_frontend in file "src/clang/Capture.ml", line 154, characters 2-37 Called from ClangFrontendClangWrapper.exe in file "src/clang/ClangWrapper.ml" (inlined), line 179, characters 15-45 Called from Stdliblist.iter in file "list.ml" (inlined), line 110, characters 12-15 Called from Stdliblist.iter in file "list.ml" (inlined), line 108, characters 13-64 Called from BaseList0.iter in file "src/list0.ml" (inlined), line 25, characters 16-35 Called from ClangFrontendClangWrapper.exe in file "src/clang/ClangWrapper.ml", line 179, characters 2-54 Called from IntegrationDriver.capture in file "src/integration/Driver.ml", line 148, characters 6-40 Called from IBaseUtils.timeit in file "src/base/Utils.ml", line 421, characters 16-20 Called from IBaseScubaLogging.execute_with_time_logging in file "src/base/ScubaLogging.ml" (inlined), line 79, characters 29-44 Called from IntegrationDriver.capture.(fun) in file "src/integration/Driver.ml", line 180, characters 2-233 Called from BackendGCStats.log_f in file "src/backend/GCStats.ml" (inlined), line 90, characters 10-14 Called from IntegrationDriver.capture in file "src/integration/Driver.ml", line 178, characters 2-288 Called from DuneexeInfer.run in file "src/infer.ml" (inlined), line 20, characters 2-36 Called from IBaseUtils.timeit in file "src/base/Utils.ml" (inlined), line 421, characters 16-20 Called from IBase__ScubaLogging.execute_with_time_logging in file "src/base/ScubaLogging.ml" (inlined), line 79, characters 29-44 Called from DuneexeInfer.run in file "src/infer.ml", line 25, characters 22-94

Run the command again with --keep-going to try and ignore this error.`

Jaya-sys commented 1 year ago

@insublee Can you assign this issue to me?