Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Interval Analysis for Floating-point values #734

Closed
Dudeldu opened this issue May 12, 2022 · 6 comments
Closed

Interval Analysis for Floating-point values #734

Dudeldu opened this issue May 12, 2022 · 6 comments
Assignees
Labels
feature precision student-job sv-comp SV-COMP (analyses, results), witnesses
Milestone

Comments

@Dudeldu
Copy link
Contributor

Dudeldu commented May 12, 2022

Issue

Current Situation

Currently, Goblint is unable to analyze double values (and for that matter, float values as well - but we will focus on
double for now).

Motivation

  • floating-point models are quite complex and features such as rounding and special numbers (infinities, NaN , etc.) are not always understood by programmers.
  • many (embedded) usecases for interaction with the real world (sensor input, motion output, etc.)
  • prominent errors with floating points have already led to catastrophic behaviors, such as the Patriot missile accident [1]

Goal

We aim to implement an interval analysis for double values. Therefore, we heavily rely on [1]. As is written there, roundings
and underflows are tolerated, but not overflows, divisions by zero or invalid operations. For these, we want goblint
to generate a warning or an error.

In a first approach, in order to be able to tackle the four different rounding modes and arbitrary precision of
intermediate results, we will implement a worst-case analysis as proposed in [1]. In other words, we won't care about
the given rounding mode and instead work conservatively with the intervals. Like this, we won't necessarily be able to
say that a program is correct, but we will be able to say if might be incorrect.

With this information we aim to provide checking of assertions and dead-branches and warnings for potential usages of invalid double values - namely NaN, +/- infinity.

Example

int main()
{
    double middle;
    double a = DBL_MAX;
    double b = DBL_MAX;

    middle = middle * 1.;  // Of course this should result in a warning, due to no information about middle and
                           // since it could therefore be NaN / infinity / neg_infinity

    middle = (a + b) / 2.; // Naive way of computing the middle, which (might) result in an overflow

    return middle - 100.   // Further uses of the overflown middle value should result in a warning
}

[1]: https://www-apr.lip6.fr/~mine/publi/article-mine-esop04.pdf

WIP here

@michael-schwarz
Copy link
Member

Nice, it's about time Goblint gets support for floating point numbers!

@sim642
Copy link
Member

sim642 commented May 12, 2022

I suppose the current goal is to add this to our base analysis's ValueDomain?

I'm just wondering, because the other angle to floating-point would be to do it in the apron analysis, since the Apron library also supports floating-point arithmetic (but we currently only use integer portions of it).

@michael-schwarz
Copy link
Member

I suppose the current goal is to add this to our base analysis's ValueDomain?

Yes! I also plan to play around with Apron's float support a bit. However, that seemed a bit involved for a practical course, and I am a bit unclear on how one would soundly handle rounding here. Also, I think having some (cheap) float support in the base analysis is crucial, as we quite often don't enable Apron for performance reasons!

@sim642
Copy link
Member

sim642 commented May 12, 2022

Indeed, having something simple which isn't Apron-based would be useful too.
I don't want to go on a tangent, but Apron expressions allow specifying some rounding modes: https://antoinemine.github.io/Apron/doc/api/ocaml/Texpr1.html#TYPEround.

@michael-schwarz
Copy link
Member

Apron expressions allow specifying some rounding modes

The question is if there is a rounding mode that is always sound or whether we have to analyze which C rounding mode is currently set which is annoying. In the thing that we'll be implementing, we are avoiding that by always rounding in the "worse" direction.

@michael-schwarz
Copy link
Member

Closed in #761

@sim642 sim642 added this to the v2.0.0 milestone Jul 27, 2022
@sim642 sim642 added the sv-comp SV-COMP (analyses, results), witnesses label Jul 27, 2022
sim642 added a commit to sim642/opam-repository that referenced this issue Aug 18, 2022
CHANGES:

Goblint "lean" release after a lot of cleanup.

* Remove unmaintained analyses: OSEK, ARINC, shapes, containment, deadlocksByRaces (goblint/analyzer#460, goblint/analyzer#736, goblint/analyzer#812, goblint/analyzer#474).
* Add interactive analysis (goblint/analyzer#391).
* Add server mode (goblint/analyzer#522).
* Add Compilation Database support (goblint/analyzer#406, goblint/analyzer#448).
* Add floating point domain, unrolled array domain and improved struct domains (goblint/analyzer#734, goblint/analyzer#761, goblint/analyzer#577, goblint/analyzer#419).
* Add static loop unrolling and heap variable unrolling (goblint/analyzer#563, goblint/analyzer#722).
* Improve race detection with may-happen-in-parallel analysis (goblint/analyzer#529, goblint/analyzer#518, goblint/analyzer#595).
* Reimplement lockset and deadlock analyses (goblint/analyzer#659, goblint/analyzer#662, goblint/analyzer#650, goblint/analyzer#655).
* Add pthread extraction to Promela (goblint/analyzer#220).
* Add location spans to output (goblint/analyzer#428, goblint/analyzer#449).
* Improve race reporting (goblint/analyzer#550, goblint/analyzer#551).
* Improve dead code reporting (goblint/analyzer#94, goblint/analyzer#353, goblint/analyzer#785).
* Refactor warnings (goblint/analyzer#55, goblint/analyzer#783).
* Add JSON schema for configuration (goblint/analyzer#476, goblint/analyzer#499).
* Refactor option names (goblint/analyzer#28, goblint/analyzer#192, goblint/analyzer#516, goblint/analyzer#675).
* Add bash completion (goblint/analyzer#669).
* Add OCaml 4.13 and 4.14 support, remove OCaml 4.09 support (goblint/analyzer#503, goblint/analyzer#672).
sim642 added a commit to sim642/opam-repository that referenced this issue Aug 18, 2022
CHANGES:

Goblint "lean" release after a lot of cleanup.

* Remove unmaintained analyses: OSEK, ARINC, shapes, containment, deadlocksByRaces (goblint/analyzer#460, goblint/analyzer#736, goblint/analyzer#812, goblint/analyzer#474).
* Add interactive analysis (goblint/analyzer#391).
* Add server mode (goblint/analyzer#522).
* Add Compilation Database support (goblint/analyzer#406, goblint/analyzer#448).
* Add floating point domain, unrolled array domain and improved struct domains (goblint/analyzer#734, goblint/analyzer#761, goblint/analyzer#577, goblint/analyzer#419).
* Add static loop unrolling and heap variable unrolling (goblint/analyzer#563, goblint/analyzer#722).
* Improve race detection with may-happen-in-parallel analysis (goblint/analyzer#529, goblint/analyzer#518, goblint/analyzer#595).
* Reimplement lockset and deadlock analyses (goblint/analyzer#659, goblint/analyzer#662, goblint/analyzer#650, goblint/analyzer#655).
* Add pthread extraction to Promela (goblint/analyzer#220).
* Add location spans to output (goblint/analyzer#428, goblint/analyzer#449).
* Improve race reporting (goblint/analyzer#550, goblint/analyzer#551).
* Improve dead code reporting (goblint/analyzer#94, goblint/analyzer#353, goblint/analyzer#785).
* Refactor warnings (goblint/analyzer#55, goblint/analyzer#783).
* Add JSON schema for configuration (goblint/analyzer#476, goblint/analyzer#499).
* Refactor option names (goblint/analyzer#28, goblint/analyzer#192, goblint/analyzer#516, goblint/analyzer#675).
* Add bash completion (goblint/analyzer#669).
* Add OCaml 4.13 and 4.14 support, remove OCaml 4.09 support (goblint/analyzer#503, goblint/analyzer#672).
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
feature precision student-job sv-comp SV-COMP (analyses, results), witnesses
Projects
None yet
Development

No branches or pull requests

7 participants