Sharing Ghost Variables in a Collection of In a Reduced Product - - PowerPoint PPT Presentation

sharing ghost variables in a collection of
SMART_READER_LITE
LIVE PREVIEW

Sharing Ghost Variables in a Collection of In a Reduced Product - - PowerPoint PPT Presentation

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J er ome Feret Problems Sharing Ghost Variables in a Collection of In a Reduced Product Abstract Domains Discussion Marc Chevalier J er ome Feret DI ENS,


slide-1
SLIDE 1

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product Discussion

Sharing Ghost Variables in a Collection of Abstract Domains

Marc Chevalier J´ erˆ

  • me Feret

DI ENS, INRIA, PSL, Paris, France

VMCAI 2020

1 / 22

slide-2
SLIDE 2

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product Discussion

Problems In a Reduced Product Discussion

2 / 22

slide-3
SLIDE 3

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems

A Big Stack A Problem Ghost Variables to the Rescue Another Problem Building a Domain with Ghost Variables A Bigger Problem

In a Reduced Product Discussion

Problems In a Reduced Product Discussion

3 / 22

slide-4
SLIDE 4

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems

A Big Stack A Problem Ghost Variables to the Rescue Another Problem Building a Domain with Ghost Variables A Bigger Problem

In a Reduced Product Discussion

A Big Stack

To certify software systems, we have to consider: ◮ End-user software (more classical) ◮ Libraries ◮ Runtime environment ◮ Operating system (here I work) ◮ Hypervisor ◮ Hardware ◮ Physics The operating system layer is the place of terrible low level operations.

4 / 22

slide-5
SLIDE 5

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems

A Big Stack A Problem Ghost Variables to the Rescue Another Problem Building a Domain with Ghost Variables A Bigger Problem

In a Reduced Product Discussion

A Problem

1

int something_interesting = ...;

2

int low = something_interesting & 0x0000ffff;

3

int high = something_interesting >> 16;

4

... // complex computations

5

int rebuilt = low | high << 16; (With enough assumptions:) something interesting = rebuilt

5 / 22

slide-6
SLIDE 6

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems

A Big Stack A Problem Ghost Variables to the Rescue Another Problem Building a Domain with Ghost Variables A Bigger Problem

In a Reduced Product Discussion

Ghost Variables to the Rescue

1

int something_interesting = ...;

2

int low = something_interesting & 0x0000ffff;

3

...

S lice[0,15]→[0,15](low)[0, 15]

low =

15 16 31

where ◮ S lice[0,15]→[0,15](low) is a ghost variable. ◮ S lice[0,15]→[0,15](low) := something interesting

6 / 22

slide-7
SLIDE 7

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems

A Big Stack A Problem Ghost Variables to the Rescue Another Problem Building a Domain with Ghost Variables A Bigger Problem

In a Reduced Product Discussion

Another Problem

1

int something_interesting_2 = ..., noise = ...;

2

int noisy = something_interesting_2 + noise;

3

...

4

int clean = noisy - noise; (With enough assumptions:) something interesting 2 = clean

7 / 22

slide-8
SLIDE 8

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems

A Big Stack A Problem Ghost Variables to the Rescue Another Problem Building a Domain with Ghost Variables A Bigger Problem

In a Reduced Product Discussion

Building a Domain with Ghost Variables

. . . Slices Underlying domain Theoretically: Parametric domain. SlicesD Implementation: Dependency injection. (Objects, templates, functors...)

8 / 22

slide-9
SLIDE 9

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems

A Big Stack A Problem Ghost Variables to the Rescue Another Problem Building a Domain with Ghost Variables A Bigger Problem

In a Reduced Product Discussion

A Bigger Problem

Slices of linear combinations:

1

int* p = ...;

2

int* q = ...;

3

int* r = p + q;

4

int l = r & 0xffff;

5

int h = r << 16;

6

... // kill r and p

7

int* r2 = l | h >> 16;

8

int* p2 = r2 - q; Linear combinations of slices:

1

int* p = ...;

2

int* n = ...;

3

int* n2 = ....;

4

int l = p & 0xffff;

5

int h = p << 16;

6

int a = l + n;

7

int b = h + n2;

8

... // kill p, l and h

9

int l2 = a - n;

10

int h2 = b - n2;

11

int* p2 = l2 | h2 >> 16;

(It happens... really)

Thus any domain should be aware of everybody helping variables.

9 / 22

slide-10
SLIDE 10

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product

Astr´ ee on the Inside The New Product in Action More? Some Legitimate Concerns: Soundness Some Legitimate Concerns: Termination

Discussion

Problems In a Reduced Product Discussion

10 / 22

slide-11
SLIDE 11

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product

Astr´ ee on the Inside The New Product in Action More? Some Legitimate Concerns: Soundness Some Legitimate Concerns: Termination

Discussion

Astr´ ee on the Inside

. . . Struct domain Pointers domain A product of numerical domains Downsides ◮ Variables ids are handled by Struct domain: missing ids for ghost variables. ◮ There is no way to add another Pointer-like domain.

11 / 22

slide-12
SLIDE 12

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product

Astr´ ee on the Inside The New Product in Action More? Some Legitimate Concerns: Soundness Some Legitimate Concerns: Termination

Discussion

Astr´ ee on the Inside – Reduced Product

Given (D♯

1, ⊆♯ 1), (D♯ 2, ⊆♯ 2), abstract domains for the same concrete

domain. Product: D♯

1×2 = D♯ 1 × D♯ 2 with pointwise operations.

γ1×2(a1, a2) = γ1(a1) ∩ γ2(a2) ρ(a1, a2) = (b1, b2) with γ1×2(a1, a2) ⊆ γ1×2(b1, b2) (sound) Morally: b1 ⊆♯

1 a1 ∧ b2 ⊆♯ 2 a2

(better)

12 / 22

slide-13
SLIDE 13

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product

Astr´ ee on the Inside The New Product in Action More? Some Legitimate Concerns: Soundness Some Legitimate Concerns: Termination

Discussion

Astr´ ee on the Inside

. . . Struct domain Pointer-adapter New combinator Numerical-adapter Product of numerical domains Pointers New combinator for pointers do- mains: ◮ Id translation by Pointer-adapter. ◮ Can add domains for pointer slices, linear combinations. . . . ◮ Cleaner interfaces. ◮ Each domain can ask everybody to store a ghost variable and do computations

  • n it.

13 / 22

slide-14
SLIDE 14

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product

Astr´ ee on the Inside The New Product in Action More? Some Legitimate Concerns: Soundness Some Legitimate Concerns: Termination

Discussion

The New Product in Action

1

int a[4], *p, *q;

2

p = &a[0];

3

q = p + 1; Before line 3: p points to a, with 0 offset. Offset stored in ghost variable op. ◮ Numerical: op = 0 ◮ Pointers: p = a + op . . . Pointer-adapter New combinator Numerical-adapter Numerical domains Pointers

14 / 22

slide-15
SLIDE 15

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product

Astr´ ee on the Inside The New Product in Action More? Some Legitimate Concerns: Soundness Some Legitimate Concerns: Termination

Discussion

The New Product in Action

1

int a[4], *p, *q;

2

p = &a[0];

3

q = p + 1; q ← p + 1: In numerical domains p = ⊤ ⇓ q = ⊤ . . . Pointer-adapter New combinator Numerical-adapter Numerical domains Pointers

14 / 22

slide-16
SLIDE 16

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product

Astr´ ee on the Inside The New Product in Action More? Some Legitimate Concerns: Soundness Some Legitimate Concerns: Termination

Discussion

The New Product in Action

1

int a[4], *p, *q;

2

p = &a[0];

3

q = p + 1; q ← p + 1: In pointer domain p = a + op ⇓ Need new offset oq and according to the semantics:

  • q← op + 1 × 4

context . . . Pointer-adapter New combinator Numerical-adapter Numerical domains Pointers

14 / 22

slide-17
SLIDE 17

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product

Astr´ ee on the Inside The New Product in Action More? Some Legitimate Concerns: Soundness Some Legitimate Concerns: Termination

Discussion

The New Product in Action

1

int a[4], *p, *q;

2

p = &a[0];

3

q = p + 1;

  • q ← op + 1 × 4:

In numerical domains

  • p = 0

  • q = 4

. . . Pointer-adapter New combinator Numerical-adapter Numerical domains Pointers

14 / 22

slide-18
SLIDE 18

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product

Astr´ ee on the Inside The New Product in Action More? Some Legitimate Concerns: Soundness Some Legitimate Concerns: Termination

Discussion

The New Product in Action

1

int a[4], *p, *q;

2

p = &a[0];

3

q = p + 1;

  • q ← op + 1 × 4:

In pointer domain

  • p ∈ NUM

  • q ∈ NUM

. . . Pointer-adapter New combinator Numerical-adapter Numerical domains Pointers

14 / 22

slide-19
SLIDE 19

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product

Astr´ ee on the Inside The New Product in Action More? Some Legitimate Concerns: Soundness Some Legitimate Concerns: Termination

Discussion

The New Product in Action

1

int a[4], *p, *q;

2

p = &a[0];

3

q = p + 1; q ← p + 1: In pointer domain p = a + op context ⇓ q = a + oq . . . Pointer-adapter New combinator Numerical-adapter Numerical domains Pointers

14 / 22

slide-20
SLIDE 20

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product

Astr´ ee on the Inside The New Product in Action More? Some Legitimate Concerns: Soundness Some Legitimate Concerns: Termination

Discussion

The New Product in Action

1

int a[4], *p, *q;

2

p = &a[0];

3

q = p + 1; After line 3: ◮ p = a + op ◮ q = a + oq ◮ op = 0 ◮ oq = 4 . . . Pointer-adapter New combinator Numerical-adapter Numerical domains Pointers

14 / 22

slide-21
SLIDE 21

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product

Astr´ ee on the Inside The New Product in Action More? Some Legitimate Concerns: Soundness Some Legitimate Concerns: Termination

Discussion

More?

Pointer-adapter New combinator New combinator Numerical-adapter Product of numerical domains Pointers Slices

15 / 22

slide-22
SLIDE 22

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product

Astr´ ee on the Inside The New Product in Action More? Some Legitimate Concerns: Soundness Some Legitimate Concerns: Termination

Discussion

Some Legitimate Concerns: Soundness

Is it correct to suspend a computation to do something else? If they are independent enough, computations commute. ⇓ Generate computations on ghostlier variables. e.g. q ← p + 1 ⇒

  • q ← op + 1 × 4

16 / 22

slide-23
SLIDE 23

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product

Astr´ ee on the Inside The New Product in Action More? Some Legitimate Concerns: Soundness Some Legitimate Concerns: Termination

Discussion

Some Legitimate Concerns: Termination

Are we sure it terminates? We consume complexity of expressions to create ghost variables ⇓ Finite number of new variables ⇓ Finite recursion depth.

17 / 22

slide-24
SLIDE 24

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product Discussion

Current Status Dialectic How Slow?! What Now?

Problems In a Reduced Product Discussion

18 / 22

slide-25
SLIDE 25

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product Discussion

Current Status Dialectic How Slow?! What Now?

Current Status

Astr´ ee: 200k OCaml. Pointer product: Astr´ ee: +30k -14k; Side effect: 10k OCaml, 10k Python It works: successfully used on serious software by industrial partner.

19 / 22

slide-26
SLIDE 26

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product Discussion

Current Status Dialectic How Slow?! What Now?

Dialectic

+ More general + Solve my problem + Solve older problems + Remove some hacks + Cleaner code (more parametric, more abstraction)

  • More internal instructions

for each real one: slower

  • Tricky to implement

And opportunistically: clean and optimize some old code I adapted.

20 / 22

slide-27
SLIDE 27

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product Discussion

Current Status Dialectic How Slow?! What Now?

How Slow?!

As of November 2019: 70 times slower.

21 / 22

slide-28
SLIDE 28

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product Discussion

Current Status Dialectic How Slow?! What Now?

How Slow?!

As of November 2019: 70 times slower. As of December 2019: 3 times slower. Phew!

21 / 22

slide-29
SLIDE 29

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product Discussion

Current Status Dialectic How Slow?! What Now?

How Slow?!

As of November 2019: 70 times slower. As of December 2019: 3 times slower. Phew! Now: still 3 times slower, but we know why and what could be done.

21 / 22

slide-30
SLIDE 30

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product Discussion

Current Status Dialectic How Slow?! What Now?

How Slow?!

As of November 2019: 70 times slower. As of December 2019: 3 times slower. Phew! Now: still 3 times slower, but we know why and what could be done. ◮ More precision through more variables ⇒ almost linear cost. ◮ Pointer-numeric adapter spend a lot of time to prepare binary

  • perations. Can be improved, heavy work.

◮ Time spend in the product within experimental fluctuations.

21 / 22

slide-31
SLIDE 31

Sharing Ghost Variables in a Collection of Abstract Domains Marc Chevalier J´ erˆ

  • me Feret

Problems In a Reduced Product Discussion

Current Status Dialectic How Slow?! What Now?

What Now?

The backbone is there: product’s advanced features, developer framework, profiling, debugging... To do: ◮ new domains ◮ better adaptation of old domains ◮ some may benefit from extra advanced features to relax some invariants.

22 / 22