Giter VIP home page Giter VIP logo

clam's Introduction

seahorn

os os Nighly Build codecov gitter

About

SeaHorn is an automated analysis framework for LLVM-based languages. This version compiles against LLVM 14.

Some of the supported features are

  • Abstract Interpretation-based static analysis
  • Unification-based Context-Sensitive pointer analysis
  • SMT-based Bounded Model Checking (i.e., symbolic execution)
  • CHC-based Software Model Checking (i.e., invariant inference)
  • Executable counterexamples (i.e., no reports, just bugs!)

SeaHorn is developed primarily as a framework for conducting research in automated verification. The frameworks provides many components that can be put together in a variety of ways. However, it is not an "out-of-the-box" static analysis tool.

Many analysis tools and examples are provided with the framework. We are constantly looking for new applications and provide support to new users. For more information on what is happening, check our (infrequently updated) blog.

License

SeaHorn is distributed under a modified BSD license. See license.txt for details.

Introduction

Demo

SeaHorn provides a python script called sea to interact with users. Given a C program annotated with assertions, users just need to type: sea pf file.c

The result of sea-pf is unsat if all assertions hold, an sat if any of the assertions are violated.

The option pf tells SeaHorn to translate file.c into LLVM bitcode, generate a set of verification conditions (VCs), and finally, solve them. The main back-end solver is spacer.

The command pf provides, among others, the following options:

  • --show-invars: display computed invariants if answer was unsat.

  • --cex=FILE : stores a counter-example in FILE if answer was sat.

  • -g : compiles with debug information for more trackable counterexamples.

  • --step=large: large-step encoding. Each transition relation corresponds to a loop-free fragments.

  • --step=small: small-step encoding. Each transition relation corresponds to a basic block.

  • --track=reg : model (integer) registers only.

  • --track=ptr : model registers and pointers (but not memory content)

  • --track=mem: model both scalars, pointers, and memory contents

  • --inline : inlines the program before verification

  • --crab : inject invariants in spacer generated by the Crab abstract-interpretation-based tool. Read here for details about all Crab options (prefix --crab). You can see which invariants are inferred by Crab by typing option --log=crab.

  • --bmc: use BMC engine.

sea pf is a pipeline that runs multiple commands. Individual parts of the pipeline can be run separately as well:

  1. sea fe file.c -o file.bc: SeaHorn frontend translates a C program into optimized LLVM bitcode including mixed-semantics transformation.

  2. sea horn file.bc -o file.smt2: SeaHorn generates the verification conditions from file.bc and outputs them into SMT-LIB v2 format. Users can choose between different encoding styles with several levels of precision by adding:

    • --step={small,large,fsmall,flarge} where small is small step encoding, large is block-large encoding, fsmall is small step encoding producing flat Horn clauses (i.e., it generates a transition system with only one predicate), and flarge: block-large encoding producing flat Horn clauses.

    • --track={reg,ptr,mem} where reg only models integer scalars, ptr models reg and pointer addresses, and mem models ptr and memory contents.

  3. sea smt file.c -o file.smt2: Generates CHC in SMT-LIB2 format. Is an alias for sea fe followed by sea horn. The command sea pf is an alias for sea smt --prove.

  4. sea clp file.c -o file.clp: Generates CHC in CLP format.

  5. sea lfe file.c -o file.ll : runs the legacy front-end

To see all the commands, type sea --help. To see options for each individual command CMD (e.g, horn), type sea CMD --help (e.g., sea horn --help).

Static Analysis with Abstract Interpretation

Inference of Inductive Invariants using Crab

SeaHorn does not use Crab by default. To enable Crab, add the option --crab to the sea command.

The abstract interpreter is by default intra-procedural and it uses the Zones domain as the numerical abstract domain. These default options should be enough for normal users. For developers, if you want to use other abstract domains you need to:

  1. Compile with cmake options -DCRAB_USE_LDD=ON -DCRAB_USE_ELINA=ON
  2. Run sea with option --crab-dom=DOM where DOM can be:
    • int for intervals
    • term-int for intervals with uninterpreted functions
    • boxes: for disjunctive intervals
    • oct for octagons
    • pk for polyhedra

To use the crab inter-procedural analysis you need to run sea with option --crab-inter

By default, the abstract interpreter only reasons about scalar variables (i.e., LLVM registers). Run sea with the options --crab-track=mem --crab-singleton-aliases=true to reason about memory contents.

How to use Invariants generated by Crab in Spacer

Crab is mostly path-insensitive while Spacer, our Horn clause solver, is path-sensitive. Although path-insensitive analyses are more efficient, path-sensitivity is typically required to prove the property of interest. This motivates our decision of running first Crab (if option --crab) and then pass the generated invariants to Spacer. There are currently two ways for Spacer to use the invariants generated by Crab. The sea option --horn-use-invs=VAL tells spacer how to use those invariants:

  • If VAL is equal to bg then invariants are only used to help spacer in proving a lemma is inductive.
  • If VAL is equal to always then the behavior is similar to bg but in addition invariants are also used to help spacer to block a counterexample.

The default value is bg. Of course, if Crab can prove the program is safe then Spacer does not incur in any extra cost.

Property Specification

Properties are assumed to be assertions. SeaHorn provides a static assertion command sassert, as illustrated in the following example

/* verification command: sea pf --horn-stats test.c */
#include "seahorn/seahorn.h"
extern int nd();

int main(void) {
    int k = 1;
    int i = 1;
    int j = 0;
    int n = nd();
    while (i < n) {
        j = 0;
        while (j < i) {
            k += (i - j);
            j++;
        }
        i++;
    }
    sassert(k >= n);
}

Internally, SeaHorn follows SV-COMP convention of encoding error locations by a call to the designated error function __VERIFIER_error(). SeaHorn returns unsat when __VERIFIER_error() is unreachable, and the program is considered safe. SeaHorn returns sat when __VERIFIER_error() is reachable and the program is unsafe. sassert() method is defined in seahorn/seahorn.h.

Inspect Code

Apart from proving properties or producing counterexamples, it is sometimes useful to inspect the code under analysis to get an idea of its complexity. For this, SeaHorn provides a command sea inspect. For instance, given a C program ex.c type:

sea inspect ex.c --sea-dsa=cs+t --mem-dot 

The option --sea-dsa=cs+t enables the new context-, type-sensitive sea-dsa analysis described in FMCAD19. This command generates a FUN.mem.dot file for each function FUN in the input program. To visualize the graph of the main function, use web graphivz interface, or the following commands:

$ dot -Tpdf main.mem.dot -o main.mem.pdf

More details on the memory graphs is in the SeaDsa repository: here.

Use sea inspect --help to see all options. Currently, the available options are:

  • sea inspect --profiler prints the number of functions, basic blocks, loops, etc.
  • sea inspect --mem-callgraph-dot prints to dot format the call graph constructed by SeaDsa.
  • sea inspect --mem-callgraph-stats prints to standard output some statstics about the call graph construction done by SeaDsa.
  • sea inspect --mem-smc-stats prints the number of memory accesses that can be proven safe by SeaDsa.

Installation

The easiest way to get started with SeaHorn is via a docker distribution.

$ docker pull seahorn/seahorn-llvm10:nightly
$ docker run --rm -it seahorn/seahorn-llvm10:nightly

Start with exploring what the sea command can do:

$ sea --help
$ sea pf --help

The nightly tag is automatically refreshed daily and contains the latest development version. We maintain all other tags (that require manual update) infrequently. Check the dates on DockerHub and log an issue on GitHub if they are too stale.

Additional examples and configuration options are on the blog. The blog is updated infrequently. In particular, options change, features are phased out, new things are added. If you find problems in the blog, let us know. We at least will update the blog post to indicate that it is not expected to work with the latest version of the code.

You can also manually install by:

Following the instructions in the Docker file Dockerfile: docker/seahorn-builder.Dockerfile.

If this does not work, run:

$ wget https://apt.llvm.org/llvm.sh
$ chmod +x llvm.sh
$ sudo ./llvm.sh 14
$ apt download libpolly-14-dev && sudo dpkg --force-all -i libpolly-14-dev*

The first 3 commands will install LLVM 14, the 4th will install libpolly which is wrongly omitted from LLVM 14 (but included in subsequent versions)

Next, follow the instruction in the Docker file above

Developer's Zone

The information from this point on is for developers only. If you would like to contribute to SeaHorn, build your own tools based on it, or just interested in how it works inside, keep reading.

Compilation Instructions

SeaHorn requires LLVM, Z3, and boost. The exact versions of the libraries keep changing, but cmake craft is used to check that right version is available.

To specify a specific version of any of the dependencies, use the usual <PackageName>_ROOT and/or <PackageName>_DIR (see find_package() for details) cmake variables.

SeaHorn is broken into multiple components that live in different repositories (under SeaHorn organization). The build process automatically checks out everything as necessary. For current build instructions, check the CI scripts.

These are the generic steps. Do NOT use them. Read on for a better way:

  1. cd seahorn ; mkdir build ; cd build (The build directory can also be outside the source directory.)
  2. cmake -DCMAKE_INSTALL_PREFIX=run ../ (Install is required!)
  3. cmake --build . --target extra && cmake .. (clones components that live elsewhere)
  4. cmake --build . --target crab && cmake .. (clones crab library)
  5. cmake --build . --target install (build and install everything under run)
  6. cmake --build . --target test-all (run tests)

Note: install target is required for tests to work!

Better Compilation Instructions

For an enhanced development experience:

  1. Use clang
  2. On Linux, use lld linker
  3. Include debug symbols in Release builds
  4. Use Ninja
  5. Export compile_commands.json

On Linux, we suggest the following cmake configuration:

$ cd build
$ cmake -DCMAKE_INSTALL_PREFIX=run \
      -DCMAKE_BUILD_TYPE=RelWithDebInfo \
      -DCMAKE_CXX_COMPILER="clang++-14" \
      -DCMAKE_C_COMPILER="clang-14" \
      -DSEA_ENABLE_LLD=ON  \
      -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
      ../ \
      -DZ3_ROOT=<Z3_ROOT> \
      -DLLVM_DIR=<LLMV_CMAKE_DIR> \
      -GNinja
$ (cd .. && ln -sf build/compile_commands.json .)

where <Z3_ROOT is a directory containing Z3 binary distribution, and LLMV_CMAKE_DIR is directory containing LLVMConfig.cmake.

Other legal options for CMAKE_BUILD_TYPE are Debug and Coverage. Note that the CMAKE_BUILD_TYPE must be compatible with the one used to compile LLVM. In particular, you will need a Debug build of LLVM to compile SeaHorn in `Debug** mode. Make sure you have plenty of patience, disk space, and time if you decide to go this route.

Alternatively, the project can be configured using cmake presets. To do this, simply run the following command:

$ cmake --preset <BUILD_TYPE>-<PRESET_NAME>

to configure cmake, where <BUILD_TYPE> is one of: Debug, RelWithDebInfo or Coverage and <PRESET_NAME> is the preset you would like to use. The presets that are currently available are: jammy. These presets assume that you have Z3 installed in /opt/z3-4.8.9 and Yices installed in /opt/yices-2.6.1.

This will also allow the project to be configured and compiled within VS Code using the CMake Tools extension.

If you would like to use different compilation settings or if you have Z3 or Yices installed in any other directory, you will need to make your own CMakeUserPresets.json file with your own presets.

Compiling on a Mac

Do not include -DSEA_ENABLE_LLD=ON. The default compiler is clang, so you might not need to set it explicitly.

The EXTRA Target

SeaHorn provides several components that are automatically cloned and installed via the extra target. These components can be used by other projects outside of SeaHorn.

  • sea-dsa: git clone https://github.com/seahorn/sea-dsa.git

    sea-dsa is a new DSA-based heap analysis. Unlike llvm-dsa, sea-dsa is context-sensitive and therefore, a finer-grained partition of the heap can be generated in presence of function calls.

  • clam: git clone https://github.com/seahorn/crab-llvm.git

    clam provides inductive invariants using abstract interpretation techniques to the rest of SeaHorn's backends.

  • llvm-seahorn: git clone https://github.com/seahorn/llvm-seahorn.git

    llvm-seahorn provides tailored-to-verification versions of InstCombine and IndVarSimplify LLVM passes as well as a LLVM pass to convert undefined values into nondeterministic calls, among other things.

SeaHorn doesn't come with its own version of Clang and expects to find it either in the build directory (run/bin) or in PATH. Make sure that the version of Clang matches the version of LLVM that was used to compile SeaHorn (currently LLVM14). The easiest way to provide the right version of Clang is to download it from llvm.org, unpact it somewhere and create a symbolic link to clang and clang++ in run/bin.

$ cd seahorn/build/run/bin
$ ln -s <CLANG_ROOT>/bin/clang clang
$ ln -s <CLANG_ROOT>/bin/clang++ clang++

where <CLANG_ROOT> is the location at which Clang was unpacked.

Tests

Testing infrastructure depends on several Python packages. These have their own dependencies. If you cannot figure them out, use docker instead.

$ pip install lit OutputCheck networkx pygraphviz

Coverage

We can use gcov and lcov to generate test coverage information for SeaHorn. To build with coverage enabled, we need to run build under a different directory and set CMAKE_BUILD_TYPE to Coverage during cmake configuration.

Example steps for generating coverage report for the test-opsem target:

  1. mkdir coverage; cd coverage create and enter coverage build directory
  2. cmake -DCMAKE_BUILD_TYPE=Coverage <other flags as you wish> ../
  3. Complete the build as usual
  4. cmake --build . --target test-opsem Run OpSem tests, now .gcda and .gcno files should be created in the corresponding CMakeFiles directories
  5. lcov -c --directory lib/seahorn/CMakeFiles/seahorn.LIB.dir/ -o coverage.info collect coverage data from desired module, if clang is used as the compiler instead of gcc, create a bash script llvm-gcov.sh:
#!/bin/bash
exec llvm-cov gcov "$@"
$ chmod +x llvm-gcov.sh

then append --gcov-tool <path_to_wrapper_script>/llvm-gcov.sh to the lcov -c ... command. 6. extract data from desired directories and generate html report:

lcov --extract coverage.info "*/lib/seahorn/*" -o lib.info
lcov --extract coverage.info "*/include/seahorn/*" -o header.info
cat header.info lib.info > all.info
genhtml all.info --output-directory coverage_report

then open coverage_report/index.html in browser to view the coverage report

Also see scripts/coverage for scripts used by the CI. Coverage report for nightly builds is available at codecov

Code indexing

Compilation database for the seahorn project and all its sub-projects is generated using -DCMAKE_EXPORT_COMPILE_COMMANDS=ON option for cmake.

An easy way to get code indexing to work with with compilation database support is to link the compilation_database.json file into the main project directory and follow instructions specific to your editor.

Remote Configuration for CLion

For a detailed guide for a remote workflow with CLion check Clion-configuration.

Remote Configuration for Emacs (and other Editors)

Use our fork of mainframer. Don't miss the example configuration.

Contributors

clam's People

Contributors

adrianherrera avatar agurfinkel avatar caballa avatar cvrac avatar gretadolcetti avatar jorgenavas avatar kuhar avatar lememta avatar linersu avatar robbepop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clam's Issues

Function @verifier.assume has invalid attributes

When using clam to insert invariants, it declares a function @verifier.assume:

; Function Attrs: inaccessiblememonly norecurse nounwind optnone
declare void @verifier.assume(i1) #1

However, attempting to disassemble the bitcode to LLVM IR generates an error as the function should also have the noinline attribute:

Attribute 'optnone' requires 'noinline'!
void (i1)* @verifier.assume
LLVM ERROR: Broken module found, compilation aborted!

I had to patch LLVM to get the .ll file and see what's going on by removing the following line: https://github.com/llvm/llvm-project/blob/97d00b72a2b0a7aca631e1402a647f32c4e8bafb/llvm/lib/IR/Verifier.cpp#L2051-L2052

PK domain is sometimes less precise than int?

Hi everyone,

I found a few interesting cases in which crab using the pk domain is less precise than when using the int domain. One example:

extern void __VERIFIER_error() __attribute__((__noreturn__));
void __VERIFIER_assert(int cond)
{
    if (!cond)
    {   
    ERROR:
        __VERIFIER_error();
    }   
}
int main() {
    int i, j, k;
    i = 0;
    j = 0;
    while (i <= 100) {
        __VERIFIER_assert(i + 1 != 0); 
        i = i + 1;
        /* this part is relevant to the reachability of the assertion */
        while (j < 20) {
            j = i + j;
        }   
    }   
    return 0;
}

I invoked crab with the following parameters:
./crabllvm.py -m 32 --crab-inter --crab-check=assert --crab-dom=int
For which the output ends in

************** ANALYSIS RESULTS ****************
1  Number of total safe checks
0  Number of total error checks
0  Number of total warning checks

Now, if switch to the pk domain (--crab-dom=pk), the output changes to

************** ANALYSIS RESULTS ****************
0  Number of total safe checks
0  Number of total error checks
1  Number of total warning checks

Is there are a particular reason for this or this is a bug?

Thank you very much,
Chris

Resolving indirect calls

So, my environment now is:

  • Ubuntu 18.04.
  • clang-5.0 (from apt).
  • crab-llvm on dev-llvm-5.0 branch.

Moreover, I compiled crab by issuing the following commands (by setting a proper value for _DIR_):

mkdir build && cd build
 cmake -DCMAKE_INSTALL_PREFIX=_DIR_ -DUSE_LDD=ON -DUSE_APRON=ON ../
 cmake --build . --target extra                 
 cmake --build . --target crab && cmake ..
 cmake --build . --target ldd && cmake ..
 cmake --build . --target apron && cmake ..
 cmake --build . --target llvm && cmake ..                
 cmake --build . --target install 

I tried to analyze this example, namely test.c:

int a (void);
int b (void);

int main(int argc, char** argv) {
  int (*p) (void);
  if (argc == 1)
      p = a;
  else
      p = b;
  int x = p();
  return 0;
}

int a() {return 10;}
int b() {return 5;}

By running:
crabllvm.py test.c --devirt-functions --crab-track=ptr --lower-select

The output is:

function main
_3:
/**
  INVARIANTS: ({}, {})
**/
  goto __@bb_1,__@bb_2;
__@bb_1:
  assume ( = 1);
  goto TrueLowerSelect;
TrueLowerSelect:
/**
  INVARIANTS: ({}, { -> [1, 1]})
**/
  PHILowerSelect = &(a) + 0;
/**
  INVARIANTS: ({}, { -> [1, 1]})
**/
  goto LowerSelect;
LowerSelect:
/**
  INVARIANTS: ({}, {})
**/
  _ret = call seahorn.bounce(PHILowerSelect:ptr);
  @V_7 = 0;
  return @V_7;
/**
  INVARIANTS: ({}, {@V_7 -> [0, 0]})
**/

__@bb_2:
  assume ( != 1);
  goto FalseLowerSelect;
FalseLowerSelect:
/**
  INVARIANTS: ({}, {})
**/
  PHILowerSelect = &(b) + 0;
/**
  INVARIANTS: ({}, {})
**/
  goto LowerSelect;

function a
_ret:
/**
  INVARIANTS: ({}, {})
**/
  @V_9 = 10;
  return @V_9;
/**
  INVARIANTS: ({}, {@V_9 -> [10, 10]})
**/


function b
_ret:
/**
  INVARIANTS: ({}, {})
**/
  @V_10 = 5;
  return @V_10;
/**
  INVARIANTS: ({}, {@V_10 -> [5, 5]})
**/

CRABLLVM WARNING: skipped indirect call. Enable --devirt-functions

function seahorn.bounce
entry:
/**
  INVARIANTS: ({}, {})
**/
  goto __@bb_1,__@bb_2;
__@bb_1:
  assume_ptr(funcPtr == b);
  goto b;
b:
/**
  INVARIANTS: ({}, {})
**/
  _1 = call b();
  UnifiedRetVal = _1;
/**
  INVARIANTS: ({}, {_1-UnifiedRetVal<=0, UnifiedRetVal-_1<=0})
**/
  goto UnifiedReturnBlock;
UnifiedReturnBlock:
/**
  INVARIANTS: ({}, {})
**/
  return UnifiedRetVal;
/**
  INVARIANTS: ({}, {})
**/

__@bb_2:
  assume_ptr(funcPtr != b);
  goto test.a;
test.a:
/**
  INVARIANTS: ({}, {})
**/
  goto __@bb_3,__@bb_4;
__@bb_3:
  assume_ptr(funcPtr == a);
  goto a;
a:
/**
  INVARIANTS: ({}, {})
**/
  _0 = call a();
  UnifiedRetVal = _0;
/**
  INVARIANTS: ({}, {_0-UnifiedRetVal<=0, UnifiedRetVal-_0<=0})
**/
  goto UnifiedReturnBlock;
__@bb_4:
  assume_ptr(funcPtr != a);
  goto default;
default:
/**
  INVARIANTS: ({}, {})
**/
  havoc(_2);
  UnifiedRetVal = _2;
/**
  INVARIANTS: ({}, {_2-UnifiedRetVal<=0, UnifiedRetVal-_2<=0})
**/
  goto UnifiedReturnBlock;
----------------------------------------------------------------------
BRUNCH_STAT Clang 0.02
BRUNCH_STAT CrabLlvm 0.00
BRUNCH_STAT CrabLlvmPP 0.00
----------------------------------------------------------------------

My doubt is double:

  1. How do I interpret the output?
  2. Even if I set --devirt-functions I get CRABLLVM WARNING: skipped indirect call. Enable --devirt-functions in the output. Why?

More general, is there a kind of guide or documentation for crab?

Thanks in advance.

Originally posted by @tregua87 in #24 (comment)

Devirtualization Error

Hi,

I'm running crabllvm-pp on this bitcode with the following commands:

./crabllvm-pp -crab-devirt -devirt-resolver=dsa -crab-lower-select -crab-lower-unsigned-icmp -o strings_pp.bc strings.bc

However, I get the following error:

#0 0x000056470871b13b llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/shankara/llvm-project/llvm/lib/Support/Unix/Signals.inc:495:0
 #1 0x000056470871b1ce PrintStackTraceSignalHandler(void*) /home/shankara/llvm-project/llvm/lib/Support/Unix/Signals.inc:559:0
 #2 0x0000564708718db2 llvm::sys::RunSignalHandlers() /home/shankara/llvm-project/llvm/lib/Support/Signals.cpp:69:0
 #3 0x000056470871ab5d SignalHandler(int) /home/shankara/llvm-project/llvm/lib/Support/Unix/Signals.inc:358:0
 #4 0x00007f3c68f51890 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #5 0x00007f3c6824de97 gsignal /build/glibc-OTsEL5/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #6 0x00007f3c6824f801 abort /build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:81:0
 #7 0x00007f3c6823f39a __assert_fail_base /build/glibc-OTsEL5/glibc-2.27/assert/assert.c:89:0
 #8 0x00007f3c6823f412 (/lib/x86_64-linux-gnu/libc.so.6+0x30412)
 #9 0x000056470766707f llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, llvm::Twine const&) /home/shankara/llvm-project/llvm/lib/IR/Instructions.cpp:372:0
#10 0x0000564706ffe778 _ZN4llvm8CallInstC4EPNS_12FunctionTypeEPNS_5ValueENS_8ArrayRefIS4_EENS5_INS_17OperandBundleDefTIS4_EEEERKNS_5TwineEPNS_11InstructionE /usr/local/include/llvm/IR/Instructions.h:1725:0
#11 0x0000564706ffe778 llvm::CallInst::Create(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&, llvm::Instruction*) /usr/local/include/llvm/IR/Instructions.h:1490:0
#12 0x0000564706ffe778 llvm::CallInst::Create(llvm::Function*, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&, llvm::Instruction*) /usr/local/include/llvm/IR/Instructions.h:1535:0
#13 0x0000564706ffe778 crab_llvm::DevirtualizeFunctions::mkDirectCall(llvm::CallSite, crab_llvm::CallSiteResolver*) /home/shankara/crab-llvm/lib/Transforms/DevirtFunctions.cc:527:0
#14 0x0000564706fffbd7 crab_llvm::DevirtualizeFunctions::resolveCallSites(llvm::Module&, crab_llvm::CallSiteResolver*) /home/shankara/crab-llvm/lib/Transforms/DevirtFunctions.cc:603:0
#15 0x0000564706ff9764 crab_llvm::DevirtualizeFunctionsPass::runOnModule(llvm::Module&) /home/shankara/crab-llvm/lib/Transforms/DevirtFunctionsPass.cc:82:0
#16 0x00005647076a5c54 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /home/shankara/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1744:0

I observed that during the devirtualization that crabllvm is reusing the bounce function:

Reusing bounce function for  call void (i8*, ...) %152(i8* %call94, %struct.bfd* %153, %struct.bfd_section* %154, %struct.reloc_cache_entry* %156)
	seahorn.bounce.16::void (void (i8*, ...)*, i8*, %struct.bfd*, %struct.bfd_section*, %struct.reloc_cache_entry*, i32)*

It seems there is this additional i32 argument which shouldn't be there.

Not Handled Expression

Hi,

I'm running crab-llvm on llvm-8.0. I am running the anlaysis on the following file and I get this error:

%.pre1 = load i8*, i8** null, align 8, !tbaa !14
main: /home/shankara/crab-llvm/sea-dsa/src/DsaLocal.cc:278: sea_dsa::Cell {anonymous}::BlockBuilderBase::valueCell(const llvm::Value&): Assertion `false && "Not handled expression"' failed.
 #0 0x0000563b7b08b915 llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/shankara/llvm-project/llvm/lib/Support/Unix/Signals.inc:495:0
 #1 0x0000563b7b08b9a8 PrintStackTraceSignalHandler(void*) /home/shankara/llvm-project/llvm/lib/Support/Unix/Signals.inc:559:0
 #2 0x0000563b7b08958c llvm::sys::RunSignalHandlers() /home/shankara/llvm-project/llvm/lib/Support/Signals.cpp:69:0
 #3 0x0000563b7b08b337 SignalHandler(int) /home/shankara/llvm-project/llvm/lib/Support/Unix/Signals.inc:358:0
 #4 0x00007f86d0443890 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #5 0x00007f86cf73fe97 gsignal /build/glibc-OTsEL5/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #6 0x00007f86cf741801 abort /build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:81:0
 #7 0x00007f86cf73139a __assert_fail_base /build/glibc-OTsEL5/glibc-2.27/assert/assert.c:89:0
 #8 0x00007f86cf731412 (/lib/x86_64-linux-gnu/libc.so.6+0x30412)
 #9 0x0000563b799e0853 (anonymous namespace)::BlockBuilderBase::valueCell(llvm::Value const&) /home/shankara/crab-llvm/sea-dsa/src/DsaLocal.cc:278:0
#10 0x0000563b799e46f5 visitPHINode /home/shankara/crab-llvm/sea-dsa/src/DsaLocal.cc:177:0
#11 0x0000563b799e46f5 visitPHI /usr/local/include/llvm/IR/Instruction.def:208:0
#12 0x0000563b799e46f5 visit /usr/local/include/llvm/IR/Instruction.def:208:0
#13 0x0000563b799e46f5 visit<llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, false> > /usr/local/include/llvm/IR/InstVisitor.h:92:0
#14 0x0000563b799e46f5 visit /usr/local/include/llvm/IR/InstVisitor.h:107:0
#15 0x0000563b799e46f5 sea_dsa::LocalAnalysis::runOnFunction(llvm::Function&, sea_dsa::Graph&) /home/shankara/crab-llvm/sea-dsa/src/DsaLocal.cc:1040:0
#16 0x0000563b799c4c2d boost::container::vector<llvm::Function const*, boost::container::new_allocator<llvm::Function const*> >::cend() const /usr/include/boost/container/vector.hpp:1403:0
#17 0x0000563b799c4c2d boost::container::vector<llvm::Function const*, boost::container::new_allocator<llvm::Function const*> >::end() const /usr/include/boost/container/vector.hpp:1351:0
#18 0x0000563b799c4c2d boost::container::container_detail::flat_tree<llvm::Function const*, boost::move_detail::identity<llvm::Function const*>, std::less<llvm::Function const*>, boost::container::new_allocator<llvm::Function const*> >::cend() const /usr/include/boost/container/detail/flat_tree.hpp:393:0
#19 0x0000563b799c4c2d boost::container::container_detail::flat_tree<llvm::Function const*, boost::move_detail::identity<llvm::Function const*>, std::less<llvm::Function const*>, boost::container::new_allocator<llvm::Function const*> >::priv_insert_unique_prepare(llvm::Function const* const&, boost::container::container_detail::flat_tree<llvm::Function const*, boost::move_detail::identity<llvm::Function const*>, std::less<llvm::Function const*>, boost::container::new_allocator<llvm::Function const*> >::insert_commit_data&) /usr/include/boost/container/detail/flat_tree.hpp:1041:0
#20 0x0000563b799c4c2d boost::container::container_detail::flat_tree<llvm::Function const*, boost::move_detail::identity<llvm::Function const*>, std::less<llvm::Function const*>, boost::container::new_allocator<llvm::Function const*> >::insert_unique(llvm::Function const*&&) /usr/include/boost/container/detail/flat_tree.hpp:443:0
#21 0x0000563b799c4c2d std::pair<boost::container::container_detail::vec_iterator<llvm::Function const**, false>, bool> boost::container::flat_set<llvm::Function const*, std::less<llvm::Function const*>, boost::container::new_allocator<llvm::Function const*> >::priv_insert<llvm::Function const*>(llvm::Function const*&&) /usr/include/boost/container/flat_set.hpp:992:0
#22 0x0000563b799c4c2d boost::container::flat_set<llvm::Function const*, std::less<llvm::Function const*>, boost::container::new_allocator<llvm::Function const*> >::insert(llvm::Function const*&&) /usr/include/boost/container/flat_set.hpp:646:0
#23 0x0000563b799c4c2d sea_dsa::ContextInsensitiveGlobalAnalysis::runOnModule(llvm::Module&) /home/shankara/crab-llvm/sea-dsa/src/DsaGlobal.cc:108:0
#24 0x0000563b7995c084 crab_llvm::SeaDsaHeapAbstraction::SeaDsaHeapAbstraction(llvm::Module&, llvm::CallGraph&, llvm::DataLayout const&, llvm::TargetLibraryInfo const&, sea_dsa::AllocWrapInfo const&, bool, bool, bool, bool) /home/shankara/crab-llvm/lib/CrabLlvm/SeaDsaHeapAbstraction.cc:563:0
#25 0x0000563b79753762 crab_llvm::CrabLlvmPass::runOnModule(llvm::Module&) /home/shankara/crab-llvm/lib/CrabLlvm/CrabLlvm.cc:1419:0
#26 0x0000563b7a06f8d4 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /home/shankara/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1744:0
#27 0x0000563b7a0700f7 llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/shankara/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1857:0
#28 0x0000563b7a070327 llvm::legacy::PassManager::run(llvm::Module&) /home/shankara/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1889:0
#29 0x0000563b794935ea run_abhaya(llvm::Module&) /home/shankara/abhaya/src/main/main.cpp:65:0
#30 0x0000563b7949390e main /home/shankara/abhaya/src/main/main.cpp:141:0
#31 0x00007f86cf722b97 __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#32 0x0000563b794929ea _start (./main+0x11f9ea)
Stack dump:
0.      Program arguments: ./main -crab-heap-analysis=ci-sea-dsa -crab-inter merged_vsftpd_pp.bc

My command is:

./crabllvm -crab-heap-analysis=ci-sea-dsa -crab-inter merged_vsftpd_pp.bc

Thanks!

Wrong order of include directories when build from SeaHorn

When crab-llvm is include in SeaHorn as a sub-project it looks first inside the installed include directories as opposed to its source location. Every time the headers change, the build fails because it finds the old header files first.

Current work-around is to delete BUILD_DIR/crab_llvm and BUILD_DIR/crab manually.

It would be more convenient if the order of include directories is fixed.

Integrate master branch from crab

From @caballa on October 15, 2016 23:46

Crab master branch changes the CFG language so the class CfgBuilder needs to be updated accordingly.

Copied from original issue: caballa/crab-llvm#5

Seemingly Spurious Bot Invariants Generated

Hi!

I'm seeing a lot of bottom invariants generated when running crab-llvm from the following file. This seems unsound as the program can reach a lot of functions on legitimate inputs in particular function do_authentication2. Any assistance would be great!

./crabllvm -crab-inter -crab-print-invariants -crab-heap-analysis=llvm-dsa sshd_pp.bc

Sea-DSA uses up a lot of memory

Hi,

This is more of a question but I'm running crab-llvm on a moderately sized llvm bitcode file here and it seems to use up 150GB of memory (don't know the upper limit as it always uses up too much). I tried to use valgrind but it was way too slow. Does what I say seem possible?

My command is:

./crabllvm -crab-inter -crab-track=arr -crab-dom=int -crab-heap-analysis=cs-sea-dsa [prog]

Regards,
Shankara

Interprocedural Invariants

Hi,

I have a simple C program like the following:

#include <unistd.h>

int add (int a) {
	if (a > 2)
		a += 4;
	else
		a += 2;
	write(1, "Hello", a);
	return a;
}

int main(int argc, char **argv) {
	int x = 4;
	add(x);
	return 0;
}

I generated the IR for this program and ran crabllvm with the following arguments:

./crabllvm -crab-inter -crab-print-invariants -crab-track=arr -crab-heap-analysis=cs-sea-dsa input.bc 

I expected crab to say that a = [4, 4] holds at the entry to add but it says that no invariants hold. Am I correct in this expectation? Thanks!

EDIT: It seems if we change the program to do just add(4) instead of add(x) I see the invariant but I'm not sure if that is to be expected.

Cannot build crab-llvm due to error: could not find svn for checkout of llvm

Hi,

I follow your tutorial at https://github.com/seahorn/crab-llvm to build crab-llvm but always encounter an issue at the command: cmake --build . --target crab && cmake ...

In brief, the error is: error: could not find svn for checkout of llvm. Below is the detailed log:

-- All crabllvm libraries will be built statically
-- Boost version: 1.58.0
-- All crab libraries will be built dynamically
-- Boost version: 1.58.0
-- The boxes domain will not be available
-- The apron domains will not be available
-- Analysis statistics is enabled
-- Analysis logging for debugging is enabled
CMake Error at /usr/share/cmake-3.5/Modules/ExternalProject.cmake:1720 (message):
  error: could not find svn for checkout of llvm
Call Stack (most recent call first):
  /usr/share/cmake-3.5/Modules/ExternalProject.cmake:2459 (_ep_add_download_command)
  CMakeLists.txt:153 (ExternalProject_Add)


-- Configuring incomplete, errors occurred!
See also "/home/trungtq/workspace/tools/crab-llvm/crab-llvm/build/CMakeFiles/CMakeOutput.log".
Makefile:606: recipe for target 'cmake_check

The commands that I run successful is:

 sudo apt-get install libboost-all-dev libboost-program-options-dev
 sudo apt-get install libgmp-dev
 sudo apt-get install libmpfr-dev	
 mkdir build && cd build
 cmake -DCMAKE_INSTALL_PREFIX=_DIR_ ../

Could you advise whether I do something incorrectly?

Thank you!

LLVM-8.0 use sea-dsa to resolve indirect calls

Hi,

I was looking at #25 and I noticed you added dsa support to resolve indirect calls. However, dsa has not been ported to 8.0 but sea-dsa has. Would it be possible to use sea-dsa to resolve indirect calls?

Specify entry point and auto generate nd values

Dear crab-llvm researchers,

I went through the possible options and the test files in the repo. They all start with the main function. I wonder if there a way to specify entry point and auto generate nd values against a testing function? For example, specify the entry point for "int get_sign(int test)" function, and auto generate a nd value for int test. If there is no way to do in current llvm-crab, my current plan is to write another llvm pass to the read the bc file for the function and read its signature.

Thank you very much.

Best,
Phil

Tag analysis questions

Hey there!

I am trying to understand the tag analysis described here. I am hoping to implement a static taint analysis using this, but am a bit confused how to do this using the current __CRAB_intrinsic_check_does_not_have_tag assert.

If I want to understand what tags (i.e., taint) can reachable a given location, what is the best way to encode this given I only have the "does not have tag" function?

Thanks so much for all of your help!

Port to LLVM 5.0

  • Ported code in branch dev-llvm-5.0
  • Pass all tests
  • Update .travis to download llvm/clang 5.0

Question: Out of memory when running on a large bitcode file

Hi, I run the following command for clam:

clam php.bc --crab-dom=int --crab-heap-analysis=none --sea-dsa=ci --sea-dsa-devirt=false --crab-check=assert

clam runs out of 200GB of memory and throws out std::bad_alloc exception:

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
clam(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x1f)[0x1ed804f]
clam(_ZN4llvm3sys17RunSignalHandlersEv+0x22)[0x1ed62e2]
clam[0x1ed8595]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x7f00769e1980]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f007548afb7]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7f007548c921]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x8c957)[0x7f0075ae1957]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x92ae6)[0x7f0075ae7ae6]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x92b21)[0x7f0075ae7b21]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x92d54)[0x7f0075ae7d54]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x932dc)[0x7f0075ae82dc]
clam(_ZN6seadsa5Graph6mkNodeEv+0x26)[0x186e546]
clam(_ZN6seadsa5Graph6mkCellERKN4llvm5ValueERKNS_4CellE+0xcb)[0x18702ab]
clam(_ZN6seadsa25CompleteCallGraphAnalysis36cloneAndResolveArgumentsAndCallSitesERKNS_11DsaCallSiteERNS_5GraphES5_b+0x141)[0x18b6a11]
clam[0x18bad7d]
clam(_ZN6seadsa25CompleteCallGraphAnalysis11runOnModuleERN4llvm6ModuleE+0x1273)[0x18b92b3]
clam(_ZN6seadsa17CompleteCallGraph11runOnModuleERN4llvm6ModuleE+0x282)[0x18bb492]
clam(_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE+0x3c0)[0xba65b0]
clam(main+0xba4)[0x773644]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7f007546dbf7]
clam(_start+0x2a)[0x77274a]
Stack dump:
0.      Program arguments: clam transed.bc --crab-dom=int --crab-heap-analysis=none --sea-dsa=ci --sea-dsa-devirt=false --crab-check=assert 
1.      Running pass 'Complete Call Graph SeaDsa pass' on module 'transed.bc'.
Aborted (core dumped)

The coredump suggests that it is related to the call graph analysis of dsa. However, I think I have already disabled dsa analysis in the above command line. How can I obtain the cheapest (maybe imprecise) command line configuration
for running clam? Thanks for your help.

fatal: Could not find the clam executable

Hi,

I am using Mac OSX catalina and follow the installation instruction.
mkdir build && cd build cmake -DCMAKE_INSTALL_PREFIX=_DIR_ -DCRAB_USE_LDD=ON -DCRAB_USE_APRON=ON ../ cmake --build . --target extra cmake --build . --target crab && cmake .. cmake --build . --target ldd && cmake .. cmake --build . --target apron && cmake .. cmake --build . --target llvm && cmake .. cmake --build . --target install

Things go smooth except I brew install svn before cmake --build . --target llvm && cmake .. .
I got installation succeed after running the above commands. However, when I run cmake --build . --target test-simple

I got
lit: [workspace]/crab-llvm/tests/lit.cfg:66: fatal: Could not find the clam executable make[3]: *** [tests/CMakeFiles/test-simple] Error 2 make[2]: *** [tests/CMakeFiles/test-simple.dir/all] Error 2 make[1]: *** [tests/CMakeFiles/test-simple.dir/rule] Error 2 make: *** [test-simple] Error 2

Thanks!

Unsoundness with recursive functions

Hi,
I was wondering whether crab-llvm handles recursive functions. Consider the following program:

extern int __VERIFIER_nondet_int();
extern void __VERIFIER_error();
void __VERIFIER_assert(int cond) {
  if (!cond) {
  ERROR: __VERIFIER_error();
  }
}

int fibo(int n) {
  // This does not hold
  __VERIFIER_assert(n != 0);
  if (n < 1) {
      return 0;
  } else if (n == 1) {
      return 1;
  } else {
      return fibo(n - 1) + fibo(n - 2);
  }
}

int main(void) {
  int x = 10;
  int result = fibo(x);
  return 0;
}

./crabllvm.py -m 32 --crab-inter --crab-check=assert --crab-dom=int /database/confrontation/crab/fibo.c yields

************** ANALYSIS RESULTS ****************
1  Number of total safe checks
0  Number of total error checks
0  Number of total warning checks
************** ANALYSIS RESULTS END*************

Another question, and only slightly related: Do crab-llvm and seahorn use the same frontend? Because as discussed in seahorn/seahorn#152, seahorn does not completely cover all potential program behavior if some part is implementation-specific (e.g. uninitialized variables). So, naturally I assumed that crab-llvm and seahorn would handle those cases similarly. Interestingly, sometimes there are still cases where crab-llvm and seahorn disagree because of undefined behavior, e.g.:

extern void __VERIFIER_error() __attribute__((__noreturn__));

void __VERIFIER_assert(int cond)
{
    if (!cond)
    {
    ERROR:
        __VERIFIER_error();
    }
    return;
}
extern int __VERIFIER_nondet_int();
int main()
{
    int i, n = __VERIFIER_nondet_int();
    if (!(n < 1000 && n >= -1000))
    {
        return 0;
    }
    __VERIFIER_assert(i <= n );
}

(seahorn: Sat, crab-llvm: Unsat)

/usr/bin/ld: cannot find -lLLVMExtensions

When I tried to build the clam, in the last few steps: it shows the following.
[ 57%] Built target SeaInstCombine
[ 57%] Building CXX object llvm-seahorn/tools/opt/CMakeFiles/seaopt.dir/AnalysisWrappers.cpp.o
[ 59%] Building CXX object llvm-seahorn/tools/opt/CMakeFiles/seaopt.dir/CallGraphPrinterWrapper.cc.o
[ 61%] Building CXX object llvm-seahorn/tools/opt/CMakeFiles/seaopt.dir/GraphPrinters.cpp.o
[ 61%] Building CXX object llvm-seahorn/tools/opt/CMakeFiles/seaopt.dir/BreakpointPrinter.cpp.o
[ 61%] Building CXX object llvm-seahorn/tools/opt/CMakeFiles/seaopt.dir/NewPMDriver.cpp.o
[ 62%] Building CXX object llvm-seahorn/tools/opt/CMakeFiles/seaopt.dir/PassPrinters.cpp.o
[ 62%] Building CXX object llvm-seahorn/tools/opt/CMakeFiles/seaopt.dir/PrintSCC.cpp.o
[ 64%] Building CXX object llvm-seahorn/tools/opt/CMakeFiles/seaopt.dir/opt.cpp.o
[ 64%] Linking CXX executable ../../../bin/seaopt
/usr/bin/ld: cannot find -lLLVMExtensions
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [llvm-seahorn/tools/opt/CMakeFiles/seaopt.dir/build.make:319: bin/seaopt] Error 1
make[1]: *** [CMakeFiles/Makefile2:2383: llvm-seahorn/tools/opt/CMakeFiles/seaopt.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 64%] Linking CXX static library ../../../lib/libSeaDsaAnalysis.a
[ 64%] Built target SeaDsaAnalysis
make: *** [Makefile:152: all] Error 2

Which part of LLVM did I miss?

I used both from the " cmake --build . --target llvm && cmake .. " and also a local version. Both had the same ld error.

Thank you very much and any suggestions would be much appreciated.

System: ubuntu 20.04

LLVM 10.0.0 is buggy, which should not be used...

CMake Option Names

Unify all top-level option name. Options related to crab-llvm should start with CLAM, options related to crab should start with CRAB. Options in crab-llvm that relate on how clam configures crab should start with CLAM_CRAB_.

For example,
USE_COTIRE --> CLAM_USE_COTIRE
BUILD_CRABLLVM_LIBS_SHARED --> 'CLAM_SHARED_LIBS ALL_CRAB_DOMAINS-->CLAM_CRAB_ENABLE_ALL_DOMAINS ENABLE_CRAB_INTER-->CLAM_CRAB_ENABLE_INTERPROC CRABLLVM_STATIC_EXE-->CLAM_STATIC_EXE`

[llvm-dis] Invalid instruction with no BB

Hello,

I get the following error if I call llvm-dis after running crab-llvm on the c code below:
llvm-dis: error: Invalid instruction with no BB (Producer: 'LLVM5.0.2' Reader: 'LLVM 5.0.2')

Information to reproduce the bug:
Crab-llvm: Docker build (i.e. with apron)

$ crabllvm --version
LLVM (http://llvm.org/):
  LLVM version 5.0.2
  Optimized build.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: sandybridge

example.c:

#include <stdio.h>

unsigned a;
unsigned x;

int main(int argc, char const* argv[])
{
    a = *(unsigned *) argv[1];
    unsigned b = a;
    unsigned c = 1;

    x = 32;
    x ^= a * 3;

    if (b == 0x55787855)
        printf("SUCCESS\n");
    else
        printf("FAILURE\n");

    printf("0x%x", x);
    return 0;
}

How to reproduce:

$ crabllvm.py example.c --crab-dom=pk --crab-track=arr --crab-add-invariants=all -o test.crab.bc
[omitted]
$ llvm-dis test.crab.bc
llvm-dis: error: Invalid instruction with no BB (Producer: 'LLVM5.0.2' Reader: 'LLVM 5.0.2')

The error occurred with the following domains:

  • pk
  • term-int
  • term-dis-int
  • rtz

Have a nice day :)

Fail to build shared library

Hey Clam devs!

I am unable to build Clam as a shared library.

Here is my build:

cmake .. -DCLAM_BUILD_LIBS_SHARED=On -DCRAB_BUILD_LIBS_SHARED=On

Doing so gives me a whole bunch of

undefined reference to `crab::domains::dis_interval<ikos::z_number>::bottom()'

Curiously, I don't see this error when building a static lib.

install clang-3.8

I am experimenting with crab-llvm.

I installed crab llvm by following the guide in the repo, everything worked well.

However, I have some trouble with clang 3.8.

It is not clear whether I should install clang 3.8 from scratch (and also a parallel llvm installation), or else I should refer to the custom clang repo here (https://github.com/seahorn/clang).

Currently, I am working with Ubuntu 18.04 and the oldest clang in apt is 3.9.

May you give me a clue about this issue, please?

Question about assertion checking?

Hi, I run clam with the following command:

clam test.bc --crab-dom=int --crab-heap-analysis=none --crab-check=assert

I have already instrumented test.bc with some __CRAB_assert checks. When the analysis finishes, clam outputs:

************** ANALYSIS RESULTS ****************
 92   Number of total safe checks
  0    Number of total error checks
128  Number of total warning checks
************** ANALYSIS RESULTS END*************

It seems that there should be 128+92=220 checking statements in test.bc. However, I find out there are
more (around 700) inserted __CRAB_assert checks in test.bc.
Why is this happening? Does clam skip the verification for some __CRAB_assert statements?

Crab Error: CFG has no exit

Hi,

I'm running crab-llvm and trying to insert invariants in the bitcode and i'm getting an error: Crab Error: CFG has no exit but I'm not sure why.

Here is the llvm bitcode and i first run crabllvm-pp as follows

./crabllvm-pp -crab-devirt -devirt-resolver=dsa -crab-lower-select -o dd_pp.bc dd.bc

Afterwards I run:

./crabllvm -crab-inter -crab-print-invariants -crab-heap-analysis=cs-sea-dsa dd_pp.bc

This produces the following:

....
WARNING: 94603348149576 is allocating a new cell.
CRABLLVM WARNING: skipped indirect call. Enabling --devirt-functions might help.
CRABLLVM WARNING: Skipped   %_6 = extractelement <2 x i64> %_5, i32 1
CRABLLVM WARNING: Skipped   %_7 = extractelement <2 x i64> %_5, i32 0
CRABLLVM WARNING: Skipped   %_9 = extractelement <2 x i64> %_8, i32 0
CRABLLVM WARNING: Skipped   %_63 = extractelement <2 x i64> %_60, i32 1
CRABLLVM WARNING: skipped indirect call. Enabling --devirt-functions might help.
CRABLLVM WARNING: skipped indirect call. Enabling --devirt-functions might help.
CRABLLVM WARNING: Skipped   %_9 = extractelement <2 x i64> %_8, i32 1
CRABLLVM WARNING: skipped indirect call. Enabling --devirt-functions might help.
CRABLLVM WARNING: skipped indirect call. Enabling --devirt-functions might help.
CRABLLVM WARNING: skipped indirect call. Enabling --devirt-functions might help.
CRABLLVM WARNING: skipped indirect call. Enabling --devirt-functions might help.
CRAB ERROR: CFG has no exit

Any assistance would be helpful and let me know if there is anything more I can provide. Thanks!

Segmentation Fault During Analysis

Hi!

I'm running crab-llvm with the following commands on this llvm-bitcode and it gives me the crash:

Command:

./crabllvm -crab-inter -crab-heap-analysis=llvm-dsa merged_ctags_pp.bc
 #4 0x00007ff9a9838890 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #5 0x00007ff9a95c1ad8 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy_chars(char*, char*, char*) (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0x124ad8)
 #6 0x000055fe20eb7414 void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag) /usr/include/c++/7/bits/basic_string.tcc:232:0
 #7 0x000055fe20ea7459 crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string::indexed_string(crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string const&) /home/shankara/crab-llvm/install/crab/include/crab/cfg/var_factory.hpp:75:0
 #8 0x000055fe20e9f693 ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string>::variable(ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string> const&) /home/shankara/crab-llvm/install/crab/include/crab/common/types.hpp:308:0
 #9 0x000055fe20ef9de6 crab::domains::flat_boolean_domain<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string>::rename(std::vector<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string>, std::allocator<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string> > > const&, std::vector<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string>, std::allocator<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string> > > const&) /home/shankara/crab-llvm/install/crab/include/crab/domains/flat_boolean_domain.hpp:565:0
#10 0x000055fe212fe2d5 crab::domains::basic_domain_product2<crab::domains::flat_boolean_domain<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string>, crab::domains::SplitDBM_<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, crab::domains::DBM_impl::DefaultParams<ikos::z_number, (crab::domains::DBM_impl::GraphRep)2> > >::second() /home/shankara/crab-llvm/crab/include/crab/domains/combined_domains.hpp:112:0
#11 0x000055fe212fe2d5 crab::domains::domain_product2<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, crab::domains::flat_boolean_domain<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string>, crab::domains::SplitDBM_<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, crab::domains::DBM_impl::DefaultParams<ikos::z_number, (crab::domains::DBM_impl::GraphRep)2> > >::rename(std::vector<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string>, std::allocator<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string> > > const&, std::vector<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string>, std::allocator<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string> > > const&) /home/shankara/crab-llvm/crab/include/crab/domains/combined_domains.hpp:574:0
#12 0x000055fe212fe2d5 crab::domains::flat_boolean_numerical_domain<crab::domains::SplitDBM_<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, crab::domains::DBM_impl::DefaultParams<ikos::z_number, (crab::domains::DBM_impl::GraphRep)2> > >::rename(std::vector<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string>, std::allocator<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string> > > const&, std::vector<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string>, std::allocator<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string> > > const&) /home/shankara/crab-llvm/crab/include/crab/domains/flat_boolean_domain.hpp:1393:0
#13 0x000055fe212fe2d5 crab::domains::array_smashing<crab::domains::flat_boolean_numerical_domain<crab::domains::SplitDBM_<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, crab::domains::DBM_impl::DefaultParams<ikos::z_number, (crab::domains::DBM_impl::GraphRep)2> > > >::rename(std::vector<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string>, std::allocator<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string> > > const&, std::vector<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string>, std::allocator<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string> > > const&) /home/shankara/crab-llvm/crab/include/crab/domains/array_smashing.hpp:451:0
#14 0x000055fe212fe2d5 crab::analyzer::summary_table<crab::cfg::cfg_ref<crab::cfg::cfg<crab_llvm::llvm_basic_block_wrapper, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, ikos::z_number> >, crab::domains::array_smashing<crab::domains::flat_boolean_numerical_domain<crab::domains::SplitDBM_<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, crab::domains::DBM_impl::DefaultParams<ikos::z_number, (crab::domains::DBM_impl::GraphRep)2> > > > >::Summary::rename(crab::domains::array_smashing<crab::domains::flat_boolean_numerical_domain<crab::domains::SplitDBM_<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, crab::domains::DBM_impl::DefaultParams<ikos::z_number, (crab::domains::DBM_impl::GraphRep)2> > > >&, std::vector<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string>, std::allocator<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string> > > const&, std::vector<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string>, std::allocator<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string> > > const&, std::vector<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string>, std::allocator<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string> > > const&, std::vector<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string>, std::allocator<ikos::variable<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string> > > const&) const /home/shankara/crab-llvm/crab/include/crab/analysis/inter_fwd_analyzer_ds.hpp:127:0
#15 0x000055fe212fe2d5 crab::analyzer::summary_table<crab::cfg::cfg_ref<crab::cfg::cfg<crab_llvm::llvm_basic_block_wrapper, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, ikos::z_number> >, crab::domains::array_smashing<crab::domains::flat_boolean_numerical_domain<crab::domains::SplitDBM_<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, crab::domains::DBM_impl::DefaultParams<ikos::z_number, (crab::domains::DBM_impl::GraphRep)2> > > > >::Summary::get_renamed_sum() const /home/shankara/crab-llvm/crab/include/crab/analysis/inter_fwd_analyzer_ds.hpp:179:0
#16 0x000055fe212fe2d5 crab::analyzer::bu_summ_abs_transformer<crab::analyzer::summary_table<crab::cfg::cfg_ref<crab::cfg::cfg<crab_llvm::llvm_basic_block_wrapper, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, ikos::z_number> >, crab::domains::array_smashing<crab::domains::flat_boolean_numerical_domain<crab::domains::SplitDBM_<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, crab::domains::DBM_impl::DefaultParams<ikos::z_number, (crab::domains::DBM_impl::GraphRep)2> > > > > >::reuse_summary(crab::domains::array_smashing<crab::domains::flat_boolean_numerical_domain<crab::domains::SplitDBM_<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, crab::domains::DBM_impl::DefaultParams<ikos::z_number, (crab::domains::DBM_impl::GraphRep)2> > > >&, crab::cfg::callsite_stmt<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string> const&, crab::analyzer::summary_table<crab::cfg::cfg_ref<crab::cfg::cfg<crab_llvm::llvm_basic_block_wrapper, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, ikos::z_number> >, crab::domains::array_smashing<crab::domains::flat_boolean_numerical_domain<crab::domains::SplitDBM_<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, crab::domains::DBM_impl::DefaultParams<ikos::z_number, (crab::domains::DBM_impl::GraphRep)2> > > > >::Summary const&) /home/shankara/crab-llvm/crab/include/crab/analysis/inter_fwd_analyzer.hpp:92:0
#17 0x000055fe2130065f crab::analyzer::bu_summ_abs_transformer<crab::analyzer::summary_table<crab::cfg::cfg_ref<crab::cfg::cfg<crab_llvm::llvm_basic_block_wrapper, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, ikos::z_number> >, crab::domains::array_smashing<crab::domains::flat_boolean_numerical_domain<crab::domains::SplitDBM_<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, crab::domains::DBM_impl::DefaultParams<ikos::z_number, (crab::domains::DBM_impl::GraphRep)2> > > > > >::exec(crab::cfg::callsite_stmt<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string>&) /home/shankara/crab-llvm/crab/include/crab/analysis/inter_fwd_analyzer.hpp:145:0
#18 0x000055fe20ee0ddc crab::analyzer::abs_transformer_api<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string>::visit(crab::cfg::callsite_stmt<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string>&) /home/shankara/crab-llvm/install/crab/include/crab/analysis/abs_transformer.hpp:138:0
#19 0x000055fe2124cc15 crab::analyzer::fwd_analyzer<crab::cfg::cfg_ref<crab::cfg::cfg<crab_llvm::llvm_basic_block_wrapper, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, ikos::z_number> >, crab::analyzer::bu_summ_abs_transformer<crab::analyzer::summary_table<crab::cfg::cfg_ref<crab::cfg::cfg<crab_llvm::llvm_basic_block_wrapper, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, ikos::z_number> >, crab::domains::array_smashing<crab::domains::flat_boolean_numerical_domain<crab::domains::SplitDBM_<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, crab::domains::DBM_impl::DefaultParams<ikos::z_number, (crab::domains::DBM_impl::GraphRep)2> > > > > > >::analyze(crab_llvm::llvm_basic_block_wrapper, crab::domains::array_smashing<crab::domains::flat_boolean_numerical_domain<crab::domains::SplitDBM_<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, crab::domains::DBM_impl::DefaultParams<ikos::z_number, (crab::domains::DBM_impl::GraphRep)2> > > >&) /home/shankara/crab-llvm/crab/include/crab/analysis/fwd_analyzer.hpp:80:0
#20 0x000055fe212bb9ed std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_is_local() const /usr/include/c++/7/bits/basic_string.h:211:0
#21 0x000055fe212bb9ed std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_dispose() /usr/include/c++/7/bits/basic_string.h:220:0
#22 0x000055fe212bb9ed _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED4Ev /usr/include/c++/7/bits/basic_string.h:647:0
#23 0x000055fe212bb9ed _ZN9crab_llvm24llvm_basic_block_wrapperD4Ev /home/shankara/crab-llvm/include/crab_llvm/crab_cfg.hh:23:0
#24 0x000055fe212bb9ed ikos::interleaved_fwd_fixpoint_iterator_impl::wto_iterator<crab::cfg::cfg_ref<crab::cfg::cfg<crab_llvm::llvm_basic_block_wrapper, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, ikos::z_number> >, crab::domains::array_smashing<crab::domains::flat_boolean_numerical_domain<crab::domains::SplitDBM_<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, crab::domains::DBM_impl::DefaultParams<ikos::z_number, (crab::domains::DBM_impl::GraphRep)2> > > > >::visit(ikos::wto_vertex<crab::cfg::cfg_ref<crab::cfg::cfg<crab_llvm::llvm_basic_block_wrapper, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, ikos::z_number> > >&) /home/shankara/crab-llvm/crab/include/crab/iterators/interleaved_fixpoint_iterator.hpp:432:0
#25 0x000055fe20f84de1 ikos::wto<crab::cfg::cfg_ref<crab::cfg::cfg<crab_llvm::llvm_basic_block_wrapper, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, ikos::z_number> > >::end() /home/shankara/crab-llvm/crab/include/crab/iterators/wto.hpp:662:0
#26 0x000055fe20f84de1 ikos::wto<crab::cfg::cfg_ref<crab::cfg::cfg<crab_llvm::llvm_basic_block_wrapper, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, ikos::z_number> > >::accept(ikos::wto_component_visitor<crab::cfg::cfg_ref<crab::cfg::cfg<crab_llvm::llvm_basic_block_wrapper, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, ikos::z_number> > >*) /home/shankara/crab-llvm/crab/include/crab/iterators/wto.hpp:684:0
#27 0x000055fe2106e439 ikos::interleaved_fwd_fixpoint_iterator<crab::cfg::cfg_ref<crab::cfg::cfg<crab_llvm::llvm_basic_block_wrapper, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, ikos::z_number> >, crab::domains::array_smashing<crab::domains::flat_boolean_numerical_domain<crab::domains::SplitDBM_<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, crab::domains::DBM_impl::DefaultParams<ikos::z_number, (crab::domains::DBM_impl::GraphRep)2> > > > >::run(crab::domains::array_smashing<crab::domains::flat_boolean_numerical_domain<crab::domains::SplitDBM_<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, crab::domains::DBM_impl::DefaultParams<ikos::z_number, (crab::domains::DBM_impl::GraphRep)2> > > >) /home/shankara/crab-llvm/crab/include/crab/iterators/interleaved_fixpoint_iterator.hpp:272:0
#28 0x000055fe2106e5d5 _ZN4crab7domains14array_smashingINS0_29flat_boolean_numerical_domainINS0_9SplitDBM_IN4ikos8z_numberENS_3cfg16var_factory_impl16variable_factoryIPKN4llvm5ValueEE14indexed_stringENS0_8DBM_impl13DefaultParamsIS5_LNSF_8GraphRepE2EEEEEEEED4Ev /home/shankara/crab-llvm/crab/include/crab/domains/array_smashing.hpp:25:0
#29 0x000055fe2106e5d5 crab::analyzer::fwd_analyzer<crab::cfg::cfg_ref<crab::cfg::cfg<crab_llvm::llvm_basic_block_wrapper, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, ikos::z_number> >, crab::analyzer::bu_summ_abs_transformer<crab::analyzer::summary_table<crab::cfg::cfg_ref<crab::cfg::cfg<crab_llvm::llvm_basic_block_wrapper, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, ikos::z_number> >, crab::domains::array_smashing<crab::domains::flat_boolean_numerical_domain<crab::domains::SplitDBM_<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, crab::domains::DBM_impl::DefaultParams<ikos::z_number, (crab::domains::DBM_impl::GraphRep)2> > > > > > >::run_forward() /home/shankara/crab-llvm/crab/include/crab/analysis/fwd_analyzer.hpp:130:0
#30 0x000055fe211e1796 crab::cfg::cfg_ref<crab::cfg::cfg<crab_llvm::llvm_basic_block_wrapper, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, ikos::z_number> >::exit() const /home/shankara/crab-llvm/crab/include/crab/cfg/cfg.hpp:3289:0
#31 0x000055fe211e1796 crab::analyzer::inter_fwd_analyzer<crab::cg::call_graph_ref<crab::cg::call_graph<crab::cfg::cfg_ref<crab::cfg::cfg<crab_llvm::llvm_basic_block_wrapper, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, ikos::z_number> > > >, crab::domains::array_smashing<crab::domains::flat_boolean_numerical_domain<crab::domains::SplitDBM_<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, crab::domains::DBM_impl::DefaultParams<ikos::z_number, (crab::domains::DBM_impl::GraphRep)2> > > >, crab::domains::array_smashing<crab::domains::flat_boolean_numerical_domain<ikos::interval_domain<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, 10ul> > > >::run(crab::domains::array_smashing<crab::domains::flat_boolean_numerical_domain<ikos::interval_domain<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, 10ul> > >) /home/shankara/crab-llvm/crab/include/crab/analysis/inter_fwd_analyzer.hpp:493:0
#32 0x000055fe2133c715 _ZN4crab7domains14array_smashingINS0_29flat_boolean_numerical_domainIN4ikos15interval_domainINS3_8z_numberENS_3cfg16var_factory_impl16variable_factoryIPKN4llvm5ValueEE14indexed_stringELm10EEEEEED4Ev /home/shankara/crab-llvm/crab/include/crab/domains/array_smashing.hpp:25:0
#33 0x000055fe2133c715 void crab_llvm::InterCrabLlvm_Impl::analyzeCg<crab::domains::array_smashing<crab::domains::flat_boolean_numerical_domain<crab::domains::SplitDBM_<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, crab::domains::DBM_impl::DefaultParams<ikos::z_number, (crab::domains::DBM_impl::GraphRep)2> > > >, crab::domains::array_smashing<crab::domains::flat_boolean_numerical_domain<ikos::interval_domain<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string, 10ul> > > >(crab_llvm::AnalysisParams const&, crab_llvm::AnalysisResults&) /home/shankara/crab-llvm/lib/CrabLlvm/CrabLlvm.cc:1057:0
#34 0x000055fe21140325 crab_llvm::InterCrabLlvm_Impl::Analyze(crab_llvm::AnalysisParams&, llvm::DenseMap<llvm::BasicBlock const*, ikos::linear_constraint_system<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string>, llvm::DenseMapInfo<llvm::BasicBlock const*>, llvm::detail::DenseMapPair<llvm::BasicBlock const*, ikos::linear_constraint_system<ikos::z_number, crab::cfg::var_factory_impl::variable_factory<llvm::Value const*>::indexed_string> > > const&, crab_llvm::AnalysisResults&) /home/shankara/crab-llvm/lib/CrabLlvm/CrabLlvm.cc:1292:0
#35 0x000055fe211409a2 _ZN4llvm8DenseMapIPKNS_10BasicBlockEN4ikos24linear_constraint_systemINS4_8z_numberEN4crab3cfg16var_factory_impl16variable_factoryIPKNS_5ValueEE14indexed_stringEEENS_12DenseMapInfoIS3_EENS_6detail12DenseMapPairIS3_SG_EEED4Ev /usr/local/include/llvm/ADT/DenseMap.h:749:0
#36 0x000055fe211409a2 crab_llvm::CrabLlvmPass::runOnModule(llvm::Module&) /home/shankara/crab-llvm/lib/CrabLlvm/CrabLlvm.cc:1448:0
#37 0x000055fe21a7a194 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /home/shankara/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1744:0
#38 0x000055fe21a7a9b7 llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/shankara/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1857:0
#39 0x000055fe21a7abe7 llvm::legacy::PassManager::run(llvm::Module&) /home/shankara/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1889:0
#40 0x000055fe20e73f3a run_abhaya(llvm::Module&) /home/shankara/abhaya/src/main/main.cpp:61:0
#41 0x000055fe20e7427b main /home/shankara/abhaya/src/main/main.cpp:137:0
#42 0x00007ff9a8b17b97 __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#43 0x000055fe20e7331a _start (./main+0x12131a)
Stack dump:

How to reproduce Elina paper results

This is from #66. I prefer to open a new issue to address it.

dengyuhui14 wrote:

I want to see if it is possible to make some improvement to the polyhedra abstract domain based on the ELINA library and Apron library. But first I need to reproduce the experiment in this paper. This paper uses crab-llvm analyzer, but it seems that I can't find crab-llvm. And I don't quite understand how analyzer and abstract domain work together to give invariants. Could you please give me some advice on how to conduct these experiment?

Replace adapt-rtz domain with a more precise version

From @caballa on October 15, 2016 23:53

It should be replaced by this domain described in Issue #8.

Currenty, adapt-rtz (adaptive reduced product of terms with zones) is really rough. For a given program we determine (via liveness analysis) the maximum number of live variables and fix for the whole program whether running with rtz or intervals. We would like to change from one domain to another at the level of basic block.

Copied from original issue: caballa/crab-llvm#6

Is it possible to integrate crab-llvm at the library level?

Hi,

I play around with your crab-llvm tool and see that it can generate many interesting invariants, such as the Apron's polka or the reduced product of intervals and congruences domain.

I would like to integrate and test it further in my project, which also uses LLVM infrastructure (but version 3.2), could you advise me a starting point so that I can pass the CFG (llvm data structures) in my project to your crab-llvm library to compute the invariant of a specific basic block?

Another off-topic question I would like to ask is that crab-llvm uses Apache license, whereas the Apron library uses LGPL license. Are these two licenses compatible?

Thank you for your time when considering my question!

Analyzing FP programs questions

Hi there!

I'm trying to implement static analysis of floating-point programs. So far when I try to use clam.py float_test.c I don't get any invariant (which makes sense since it only works on integers). I was wondering if I can get some pointers on what would be required to support FP variables in clam so I can try to implement it if possible.

Thank you for all the help!

Add nullity analysis

From @caballa on October 15, 2016 23:55

Add a nullity analysis. This requires to resolve first Issues #4 and #5

Copied from original issue: caballa/crab-llvm#7

question about --crab-bounds-check

Hi Seahorn Team,

Q1: is --crab-bounds-check for buffer overflow?
Q2: I don't find documentation regarding this option, is it deprecated?
Q3: I open this option but return -- Inserted 0 bound checks every time, Do I need to insert something to source code to enable it?

Thank you.

Possibly stack overflow while computing WTO of a large CFG

Problem07_label52_true-unreach-call.pp.bc.zip

Command:

crabllvm Problem07_label52_true-unreach-call.pp.bc  --crab-verbose=2 --crab-dom=int --crab-widening-delay=2 --crab-widening-jump-set=0 --crab-narrowing-iterations=2 --crab-track=arr --crab-singleton-aliases  --crab-check=assert --crab-stats --crab-disable-warnings

silently produces signal 11 (SEGFAULT).
I did some gdb and it seems that we run out of stack while computing WTO using recursion.

ICE error with the head of master tree

Hi ,
I've got this ICE error when compling the head master tree,
my gcc version is 5.5.0
[ 19%] Building CXX object lib/CrabLlvm/CMakeFiles/CrabLlvmInstrumentation.dir/InsertInvariants.cc.o

c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See file:///usr/share/doc/gcc-5/README.Bugs for instructions.
lib/CrabLlvm/CMakeFiles/CrabLlvmInstrumentation.dir/build.make:62: recipe for target 'lib/CrabLlvm/CMakeFiles/CrabLlvmInstrumentation.dir/InsertInvariants.cc.o' failed
make[2]: *** [lib/CrabLlvm/CMakeFiles/CrabLlvmInstrumentation.dir/InsertInvariants.cc.o] Error 4
CMakeFiles/Makefile2:1367: recipe for target 'lib/CrabLlvm/CMakeFiles/CrabLlvmInstrumentation.dir/all' failed
make[1]: *** [lib/CrabLlvm/CMakeFiles/CrabLlvmInstrumentation.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

Crab CFG has no exit

Hi!

Thanks for your help on previous issues. I'm on llvm-8.0 branch and I'm getting the error CRAB ERROR: CFG has no exit when running crabllvm on this file.

My specific commands are:

./crabllvm -crab-inter -crab-heap-analysis=ci-sea-dsa sshd_pp.bc

Precise translation of boolean operations

The solution is to translate all comparison instructions that do not feed branches and Boolean operations to crab Boolean operations. In that way, the abstract domain will decide what to do. Until now, we were assuming that the abstract domain does not have knowledge about Boolean operations so the translation tried to reduce all Boolean operations to expensive crab select statements.

cannot build crab-llvm due to an ocaml-llvm binding issue

Hi,

When building crab-llvm, I encountered an error at the step:

cmake --build . --target llvm && cmake ..

The reason is due to the compilation of ocaml-llvm binding. Here is the detailed log produced in the file crab-llvm/build/llvm-prefix/src/llvm-stamp/llvm-build-err.log.

File "llvm_executionengine.ml", line 54, characters 28-77:
Error: This expression has type nativeint
       but an expression was expected of type int64
make[6]: *** [bindings/ocaml/executionengine/llvm_executionengine.cma] Error 2
make[5]: *** [bindings/ocaml/executionengine/CMakeFiles/ocaml_llvm_executionengine.dir/all] Error 2
make[4]: *** [all] Error 2

This issue occurs with both OCaml 4.02.3 and OCaml 4.04.0 I googled for the solution of this issue but there is not much information, except the bug report: http://lists.llvm.org/pipermail/llvm-bugs/2015-June/040629.html

Do you know how to overcome this issue?

Thank you!

Docker Pull not Working

I was trying to install from docker using the suggested command:
docker pull seahorn/clam_5.0:latest
But I keep getting the following error
Error response from daemon: manifest for seahorn/clam_5.0:latest not found: manifest unknown: manifest unknown
I am using Docker version 19.03.4, build 9013bf583a on Debian GNU/Linux 9 (stretch)

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.