Skip to content

Commit 8651ad3

Browse files
author
martin
committed
Crashing test cases due to pointer arithmetic issues.
1 parent 8cce1c5 commit 8651ad3

File tree

5 files changed

+57
-1
lines changed

5 files changed

+57
-1
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// map.c
2+
int map(int t_x, int * p_map) // mismatch :(
3+
{
4+
int n = p_map[0];
5+
int *p_map_x = &p_map[1];
6+
int *p_map_y = p_map_x + n ; // assertion failed here
7+
int i;
8+
9+
if (t_x < p_map_x[0])
10+
return p_map_y[0];
11+
12+
for (i=1; i<n; i++)
13+
if (t_x < p_map_x[i])
14+
{
15+
int x0 = p_map_x[i-1];
16+
int x1 = p_map_x[i];
17+
int y0 = p_map_y[i-1];
18+
int y1 = p_map_y[i];
19+
return (y1-y0)/(x1-x0) * (t_x-x0) + y0;
20+
}
21+
22+
return p_map_y[n-1];
23+
}
24+
25+
/// file2.c
26+
int map(int t_x, volatile const int* p_map);
27+
volatile const int s_map_data[] = { 2, 10, 20, 100, 110 };
28+
extern int g_x;
29+
int g_y;
30+
31+
void main(void)
32+
{
33+
g_y = map(g_x, s_map_data);
34+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
KNOWNBUG
2+
main.c
3+
--variable-sensitivity --structs --arrays --pointers --show
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
void main(void)
2+
{
3+
const int s_map_data[] = { 2, 10, 20, 100, 110 };
4+
5+
int *p_map_x = &s_map_data[1];
6+
int *p_map_y = p_map_x + 1 ; // assertion failed here
7+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
KNOWNBUG
2+
main.c
3+
--variable-sensitivity --structs --arrays --pointers --show
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--

src/analyses/variable-sensitivity/abstract_enviroment.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,10 @@ bool abstract_environmentt::assign(
230230
const typet &rhs_type=ns.follow(final_value->type());
231231

232232
// Write the value for the root symbol back into the map
233-
INVARIANT(lhs_type==rhs_type, "Assignment types must match");
233+
INVARIANT(lhs_type==rhs_type,
234+
"Assignment types must match" "\n"
235+
"lhs_type :" + lhs_type.pretty() + "\n"
236+
"rhs_type :" + rhs_type.pretty());
234237
// If LHS was directly the symbol
235238
if(s.id()==ID_symbol)
236239
{

0 commit comments

Comments
 (0)