Code Monkey home page Code Monkey logo

tinybct's Introduction

TinyBCT

TiniBCT is a MSIL translator to Boogie PL. It relies on a .NET analysis Framework to parse and analyze the MSIL.

For latest changes use the develop branch.

Build Status

Master Develop
master build status develop build status

Usage

TinyBCT -i [souclist of DLLs/EXEs to transalate]

The output is a bpl file containting the translation of all source files.

Additional options

  • -b [list bpl files]: include this files to the output blp
  • -l true: add line numbers

Build for Linux/MacOS

The following steps are to build TinyBCT.exe only not the test unit suite. In order to do that, you may require to use a specific version of mono (check travis file for more details).

You must install:

  1. https://www.mono-project.com/download/stable/
  2. https://dotnet.microsoft.com/download/linux-package-manager/ubuntu18-04/sdk-current
  3. sudo apt-get install nuget

In the repository folder, you must execute:

  1. git checkout develop
  2. git submodule update --init --recursive
  3. nuget restore
  4. msbuild TinyBCT/TinyBCT.csproj

Page in construction

tinybct's People

Contributors

m-carrasco avatar rcastano avatar garbervetsky avatar michael-emmi avatar

Stargazers

Allister Beharry avatar Edgardo Zoppi avatar  avatar

Watchers

 avatar  avatar  avatar Fernan Martinelli avatar  avatar

tinybct's Issues

Box/Unbox

Jolden required the implementation of boxing. I have not implemented yet the unboxing neither tests.

keyword "ref"

Not sure if this keyword is supported, neither how it should be implemented.

Real type in BCT and TinyBCT

BCT models Real type as a new type declared in their Prelude. In TinyBCT we are using the real type supported by the Boogie language.

Not sure if we have seen how BCT works on this type.

Documentation regarding exceptions

Exceptions in Boogie are handled with a global variable. Therefore you may have to pay attention about it being initialized.

After a call method the global exception variable is checked in order to propagate exceptions.

TinyBCT creates for each main method a wrapper, in which global variables are initialized (in addition static constructors are called).

The following test will document the behavior when a no main method is used as an entry point.

class ExceptionTestInitializeExceptionVariable
{
    // if this method is used as an entry point
    // global exception variable won't be initialized
    // after safe() is called, the exception variable could be on
    // because it was not initialized

    // TinyBCT generates a wrapper for each main method found 
    // wrappers initialize global variables

    public static void test()
    {
        try
        {
            safe();
        } catch (Exception ex)
        {
            Contract.Assert(false);
        }
    }
    public static void safe() {}
}

The example is in our test suite

    [TestMethod, Timeout(10000)]
    [TestCategory("Manu")]
    public void ExceptionTestInitializeExceptionVariable()
    {
        var corralResult = CorralTestHelper("Exceptions", "Test.ExceptionTestInitializeExceptionVariable.test", 10);
        Assert.IsTrue(corralResult.AssertionFails());
    }

Corral reports that the assertion can fail.

Coercion: Improve precision

Currently we model casts as havocs in all cases. But we could avoid that for all casts among integers types or among floating point types (but not across).

Document deliberate imprecision and unsoundness

While adding support for less frequent instructions, we often decide to approximate the desired behavior until the need for further precision/soundness arises.
We've also taken implementation decisions that are catered to the use cases we currently have in mind (angelic verification and generating enabledness preserving abstractions) but could lead to undesired results under other use cases.

It'd be ideal to find a way to gather all those implementation decisions and document them in one place.

Add CI to the repository

Having CI set up within the repository would help us maintain a working version at all times and detect problems earlier.

Helpers.GetBoogieType

This method can return null, check every dependency on that value. We want to eliminate the dependency on null values.

Casts could throw exceptions

Currently we model casts with havocs, but we don't consider the possibility of an InvalidCastException being thrown. We should consider whether we want to generate this in our translation.

'default' keyword

Current support is very rudimentary. It'd be ideal to find and document cases where it breaks, paying special attention to interactions with generics

Propagate type information in Boogie

When using an open entry point (method with parameters), if we use objects from the heap, there aren´t any assumptions about its type. By propagating information from method parameters and load instructions, we can work around this.

Possible bug related to subtyping information for method parameters

We identified a possible bug but haven't been able to reproduce it yet.
My hypothesis is that the following assumption might lead to unexpected results, but I'm not sure what sort of assertion would be problematic.

void Foo(H<T> x) {
  assume Subtype(DynamicType(x), H($T()))
}

The potential fix would be to use assume TypeConstructor(DynamicType(x)) == H;.

split the heap

We are currently modeling the heap as a single bi-dimensional map. This isn't a convenient representation for subsequent analyses on the Boogie code. The desired representation would emulate the treatment of BCT using the /heap:splitFields command line flag.

Possibly omit additional subtyping axioms when not necessary

The recent fix for issue #29 causes TinyBCT to generate larger Boogie files (longer axioms). We should try to find a way to resort to shorter axioms when possible.

This might deserve a more involved discussion and evaluation of the actual impact on performance.

Loops translation, comparison between TinyBCT and BCT

Here is an example of a loop translated by TinyBCT in which corral reaches the recursion bound. However the same loop translated by BCT, corral is able to prove no bugs without reaching the recursion bound.

The procedure (name in dll) is STATE$System_Collections2_Queue_ContainsSystem_Object$System_Collections2_Queue_EnqueueSystem_ObjectSystem_Collections2_Queue_ContainsSystem_ObjectSystem_Collections2_Queue_ContainsSystem_Object

It is declared in System.Collections2.Queue

The BCT version that I used is the present in contractor-net dependencies folder.

Queue.zip
Password: tinybct

Missing file?

Missing file in tests:
"Source file 'C:\Users\Doc\repos\TinyBCT\Test\Loops.cs' could not be found."

Missing instructions support

The following instructions are not implemented and required by Jolden.

  • UnaryInstruction
  • LoadTokenInstruction
  • SwitchInstruction

LoadTokenInstruction appears in the Root class static constructor.

Unify null name with BCT

I think BCT uses 'NULL' whereas we use 'null'. This might create issues with angelic verification.

Create documentation

Setting up the project and running the tests require a few non-trivial steps which should be documented.

We also need documentation of the high-level architecture of the project and design/implementation decisions for new contributors.

Ideally we'd want to also have a few smaller 'nice to have' projects that are suitable as a first issue to work on.

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.