Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
70f692b5
Commit
70f692b5
authored
4 years ago
by
Allan Blanchard
Browse files
Options
Downloads
Patches
Plain Diff
[rte/doc] Fixes documentation
parent
2455136e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
doc/rte/rte.tex
+22
-16
22 additions, 16 deletions
doc/rte/rte.tex
src/plugins/rte/options.ml
+1
-1
1 addition, 1 deletion
src/plugins/rte/options.ml
src/plugins/rte/rte.ml
+1
-1
1 addition, 1 deletion
src/plugins/rte/rte.ml
with
24 additions
and
18 deletions
doc/rte/rte.tex
+
22
−
16
View file @
70f692b5
...
@@ -7,6 +7,9 @@
...
@@ -7,6 +7,9 @@
\newcommand
{
\optnodowncast
}{
\mbox
{
\lstinline
|-rte-no-downcast|
}}
\newcommand
{
\optnodowncast
}{
\mbox
{
\lstinline
|-rte-no-downcast|
}}
\newcommand
{
\rte
}{
\textsf
{
RTE
}
\xspace
}
\newcommand
{
\rte
}{
\textsf
{
RTE
}
\xspace
}
\newcommand
{
\framac
}{
\textsf
{
Frama-C
}
\xspace
}
\newcommand
{
\framac
}{
\textsf
{
Frama-C
}
\xspace
}
\newcommand
{
\acsl
}{
\textsf
{
ACSL
}
\xspace
}
\newcommand
{
\gcc
}{
\textsf
{
Gcc
}
\xspace
}
\newcommand
{
\clang
}{
\textsf
{
Clang
}
\xspace
}
\tableofcontents
\tableofcontents
...
@@ -443,7 +446,7 @@ Dereferencing a pointer is an undefined behavior if:
...
@@ -443,7 +446,7 @@ Dereferencing a pointer is an undefined behavior if:
\end{itemize}
\end{itemize}
The
\rte
{}
plug-in generates annotations to prevent this type of undefined
The
\rte
{}
plug-in generates annotations to prevent this type of undefined
behavior in a systematic way. It does so by deferring the check to the
ACSL
behavior in a systematic way. It does so by deferring the check to the
\acsl
{}
built-in predicate
\lstinline
|valid(p)|:
\lstinline
|valid(s)| (where
built-in predicate
\lstinline
|valid(p)|:
\lstinline
|valid(s)| (where
\lstinline
|s| is a set of terms) holds if and only if dereferencing any
\lstinline
|s| is a set of terms) holds if and only if dereferencing any
$
\lstinline
|p|
\in
\lstinline
|s|
$
is safe (i.e. points to a safely allocated
$
\lstinline
|p|
\in
\lstinline
|s|
$
is safe (i.e. points to a safely allocated
...
@@ -681,7 +684,7 @@ int f(float v) {
...
@@ -681,7 +684,7 @@ int f(float v) {
\section
{
Expressions not considered by
\rte
{}}
\section
{
Expressions not considered by
\rte
{}}
An expression which is the operand of a
\lstinline
|sizeof| (or
An expression which is the operand of a
\lstinline
|sizeof| (or
\lstinline
|
__
alignof|, a
GCC
operator parsed by Cil) is ignored by
\rte
{}
, as
\lstinline
|
__
alignof|, a
\gcc
{}
operator parsed by Cil) is ignored by
\rte
{}
, as
are all its sub-expressions. This is an approximation, since the operand of
are all its sub-expressions. This is an approximation, since the operand of
\lstinline
|sizeof| may sometimes be evaluated at runtime, for instance on
\lstinline
|sizeof| may sometimes be evaluated at runtime, for instance on
variable sized arrays: see the example in
\cnn
{}
paragraph
\mbox
{
6.5.3.4.7
}
.
variable sized arrays: see the example in
\cnn
{}
paragraph
\mbox
{
6.5.3.4.7
}
.
...
@@ -740,8 +743,8 @@ int main(void)
...
@@ -740,8 +743,8 @@ int main(void)
\section
{
Initialization
}
\section
{
Initialization
}
Reading an uninitialized value can be an undefined behavior
. Mostly two general
Reading an uninitialized value can be an undefined behavior
in the two following
cases
apply
:
cases:
\begin{itemize}
\begin{itemize}
\item
\mbox
{
ISO C11 6.3.2.1
}
\footnote
{
here we use C11 as it is clearer than C99
}
\item
\mbox
{
ISO C11 6.3.2.1
}
\footnote
{
here we use C11 as it is clearer than C99
}
...
@@ -750,10 +753,10 @@ cases apply:
...
@@ -750,10 +753,10 @@ cases apply:
that it was a trap representation for the type used for the access.
that it was a trap representation for the type used for the access.
\end{itemize}
\end{itemize}
The second item is the consequence of the fact that
an uninitialized location
More generally, reading
an uninitialized location
always results in an
has
indeterminate value (
\mbox
{
6.7.9.10
}
)
, thu
s either an unspecified
value or
indeterminate value (
\mbox
{
6.7.9.10
}
)
. Such a value i
s either an unspecified
a trap representation
, and that
reading a trap representation is an
undefined
value or
a trap representation
. Only
reading a trap representation is an
behavior (
\mbox
{
6.2.6.1.5
}
).
undefined
behavior (
\mbox
{
6.2.6.1.5
}
).
It corresponds to the second case above.
However for (most) types that do not have trap representation, reading an
However for (most) types that do not have trap representation, reading an
unspecified value is generally not a desirable behavior. Thus,
\rte
{}
is
unspecified value is generally not a desirable behavior. Thus,
\rte
{}
is
...
@@ -765,19 +768,20 @@ a typedef of those) is read, it must be initialized except if it is a formal
...
@@ -765,19 +768,20 @@ a typedef of those) is read, it must be initialized except if it is a formal
parameter or a global variable. We exclude formal parameters as its
parameter or a global variable. We exclude formal parameters as its
initialization status must be checked at the call point (
\rte
{}
generates an
initialization status must be checked at the call point (
\rte
{}
generates an
annotation for this). We exclude global variables as they are initialized by
annotation for this). We exclude global variables as they are initialized by
default and any value stored in this variable must be initialized (
and
\rte
{}
default and any value stored in this variable must be initialized (
\rte
{}
generates an annotation for this).
generates an annotation for this).
As structures and unions never have trap representation, they can (and they are
As structures and unions never have trap representation, they can (and they are
regularly) be manipulated while being partially initialized. Consequently,
regularly) be manipulated while being partially initialized. Consequently,
\rte
{}
does not requires initialization for reads of a full union or structure
\rte
{}
does not require initialization for reads of a full union or structure
(while read field with fundamental types are covered by the previous paragraph).
(while reading fields with fundamental types is covered by the previous paragraph).
As a consequence, the case of a structure or union
\textit
{
whose address is never
As a consequence, the case of structures and unions
\textit
{
whose address is
taken is read before being initialized
}
is
\textbf
{
not
}
covered by
\rte
{}
. But
never taken, and being read before being initialized
}
is
\textbf
{
not
}
covered
by
\rte
{}
. It is worth noting that
this particular case is efficiently detected by a compiler warning (see
this particular case is efficiently detected by a compiler warning (see
\lstinline
{
-Wuninitialized
}
on
GCC
and
C
lang for example) as it only
requires
\lstinline
{
-Wuninitialized
}
on
\gcc
{}
and
\c
lang
{}
for example) as it only
local reasoning that is easy for compilers (but not that simple to
express in
requires
local reasoning that is easy for compilers (but not that simple to
ACSL
).
express in
\acsl
{}
).
If you really need
\rte
{}
to cover the previous case, please contact the
If you really need
\rte
{}
to cover the previous case, please contact the
Frama-C team.
Frama-C team.
...
@@ -787,6 +791,8 @@ cannot have trap representation (for example \lstinline{unsigned char}) should
...
@@ -787,6 +791,8 @@ cannot have trap representation (for example \lstinline{unsigned char}) should
be allowed, for example writing a
\lstinline
{
memcpy
}
function. In this case, one
be allowed, for example writing a
\lstinline
{
memcpy
}
function. In this case, one
can exclude this function from the range of function annotated with
can exclude this function from the range of function annotated with
initialization properties using
\lstinline
{
-rte-initialized-ignore
}
.
initialization properties using
\lstinline
{
-rte-initialized-ignore
}
.
Note that the excluded functions must preserve the initialization of globals, as
no assertions are generated for them.
\section
{
Undefined behaviors not covered by
\rte
{}}
\section
{
Undefined behaviors not covered by
\rte
{}}
...
...
This diff is collapsed.
Click to expand it.
src/plugins/rte/options.ml
+
1
−
1
View file @
70f692b5
...
@@ -68,7 +68,7 @@ module DoInitialized =
...
@@ -68,7 +68,7 @@ module DoInitialized =
(
struct
(
struct
let
option_name
=
"-rte-initialized"
let
option_name
=
"-rte-initialized"
let
help
=
"when on, annotates local variables and pointers \
let
help
=
"when on, annotates local variables and pointers \
reads of non struct types with initialization tests \
reads of non struct
or union
types with initialization tests \
see documentation for more details."
see documentation for more details."
end
)
end
)
...
...
This diff is collapsed.
Click to expand it.
src/plugins/rte/rte.ml
+
1
−
1
View file @
70f692b5
...
@@ -110,7 +110,7 @@ let lval_initialized_assertion ~remove_trivial:_ ~on_alarm lv =
...
@@ -110,7 +110,7 @@ let lval_initialized_assertion ~remove_trivial:_ ~on_alarm lv =
match
lv
with
match
lv
with
|
Var
vi
,
NoOffset
->
|
Var
vi
,
NoOffset
->
(** Note: here [lv] has structure/union type or fundamental type.
(** Note: here [lv] has structure/union type or fundamental type.
We exclude structure and unions. And for fundamental types:
We exclude structure
s
and unions. And for fundamental types:
- globals (initialized and then only written with initialized values)
- globals (initialized and then only written with initialized values)
- formals (checked at function call)
- formals (checked at function call)
- temporary variables (initialized during AST normalization)
- temporary variables (initialized during AST normalization)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment