Skip to content
Snippets Groups Projects
Commit 064abc1f authored by Erwan Jahier's avatar Erwan Jahier
Browse files

-exec: don't crash when integers overflow when reading inputs and try

to behave as scanf("%d")

(the function that perform this job is actually in rdbg-plugin so that it is shared
with lutin and rdbg)
parent 5ee67626
No related branches found
No related tags found
No related merge requests found
......@@ -40,3 +40,5 @@ let rec pos_in_list i x l =
match l with
| e::l -> if e=x then i else pos_in_list (i+1) x l
| [] -> assert false (* should not occur *)
let my_int_of_string = LocalGenlex.local_int_of_string
......@@ -53,22 +53,6 @@ let get_string () =
(* The lexer *)
(* Avoid crashing if int are too big *)
let my_int_of_string str =
try int_of_string str
with _ ->
let i64 = Int64.of_string str in
let i = if i64 > (Int64.of_int max_int) then
max_int / 4
else if i64 < (Int64.of_int min_int) then
min_int / 4
else
Int64.to_int i64 (* deadcode IMHO *)
in
Printf.eprintf "Warning: The integer %s is too big: truncate it to %i\n" str i;
flush stderr;
i
let make_lexer keywords =
let kwd_table = Hashtbl.create 17 in
......@@ -162,7 +146,7 @@ let make_lexer keywords =
| _ ->
let s = (get_string ()) in
Some (Int ((debut,(Stream.count strm__)),
(my_int_of_string s)
(lv6Util.my_int_of_string s)
))
and decimal_part (strm__ : _ Stream.t) =
let debut = Stream.count strm__ in
......
(* Time-stamp: <modified the 22/08/2014 (at 15:08) by Erwan Jahier> *)
(* Time-stamp: <modified the 02/09/2014 (at 14:03) by Erwan Jahier> *)
let dbg = (Verbose.get_flag "exec")
......@@ -245,13 +245,15 @@ fun id ctx ->
print_string ("get_enum '" ^ (val_to_string string_of_float o) ^"' failed\n"); flush stdout;
assert false (* should not fail *)
let rec (get_value : ctx -> var_expr -> Data.v) =
fun ctx v ->
match v with
| Var(id,_) -> get_val id ctx
| Const(("true"|"t"|"_true"), Bool) -> B true
| Const(("false"|"f"|"_false"), Bool) -> B false
| Const(id_in,Int) -> I (int_of_string id_in)
| Const(id_in,Int) -> I (Lv6util.my_int_of_string id_in)
| Const(id_in,Real) -> F (float_of_string id_in)
| Const(id,Enum(_,idl)) -> E(id, Lv6util.pos_in_list 0 id idl)
| Const(id,Array(_vt,i)) -> get_val id ctx
......
==> lus2lic0.sum <==
Test Run By jahier on Tue Sep 2 10:30:37
Test Run By jahier on Wed Sep 3 09:14:01
Native configuration is i686-pc-linux-gnu
=== lus2lic0 tests ===
......@@ -63,7 +63,7 @@ XFAIL: Test bad programs (assert): test_lus2lic_no_node should_fail/assert/s.lus
XFAIL: Test bad programs (assert): test_lus2lic_no_node should_fail/assert/eq1.lus
==> lus2lic1.sum <==
Test Run By jahier on Tue Sep 2 10:30:37
Test Run By jahier on Wed Sep 3 09:14:01
Native configuration is i686-pc-linux-gnu
=== lus2lic1 tests ===
......@@ -402,7 +402,7 @@ PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c Gyroscope.lus {}
PASS: ./lus2lic {-2c Int.lus -n Int}
==> lus2lic2.sum <==
Test Run By jahier on Tue Sep 2 10:30:39
Test Run By jahier on Wed Sep 3 09:14:01
Native configuration is i686-pc-linux-gnu
=== lus2lic2 tests ===
......@@ -599,7 +599,7 @@ PASS: gcc -o test.exec test_test.c test_test_loop.c
PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c test.lus {}
PASS: ./lus2lic {-2c test_node_expand.lus -n test_node_expand}
PASS: gcc -o test_node_expand.exec test_node_expand_test_node_expand.c test_node_expand_test_node_expand_loop.c
FAIL: Try to compare lus2lic -exec and -2c: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c test_node_expand.lus {}
PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c test_node_expand.lus {}
PASS: ./lus2lic {-2c test_clash.lus -n test_clash}
PASS: ./lus2lic {-2c trivial.lus -n trivial}
PASS: gcc -o trivial.exec trivial_trivial.c trivial_trivial_loop.c
......@@ -690,6 +690,9 @@ PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c zzz.lus {}
PASS: ./lus2lic {-2c PCOND1.lus -n PCOND1}
PASS: gcc -o PCOND1.exec PCOND1_PCOND1.c PCOND1_PCOND1_loop.c
PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c PCOND1.lus {}
PASS: ./lus2lic {-2c PCOND.lus -n PCOND}
PASS: gcc -o PCOND.exec PCOND_PCOND.c PCOND_PCOND_loop.c
FAIL: Try to compare lus2lic -exec and -2c: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c PCOND.lus {}
PASS: ./lus2lic {-2c SWITCH.lus -n SWITCH}
PASS: gcc -o SWITCH.exec SWITCH_SWITCH.c SWITCH_SWITCH_loop.c
PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c SWITCH.lus {}
......@@ -720,7 +723,7 @@ PASS: gcc -o X.exec X_X.c X_X_loop.c
PASS: /home/jahier/lus2lic/test/../utils/compare_exec_and_2c X.lus {}
==> lus2lic3.sum <==
Test Run By jahier on Tue Sep 2 10:30:39
Test Run By jahier on Wed Sep 3 09:14:04
Native configuration is i686-pc-linux-gnu
=== lus2lic3 tests ===
......@@ -1220,7 +1223,7 @@ PASS: ./lus2lic {-ec -o Int.ec Int.lus}
PASS: ./myec2c {-o Int.c Int.ec}
==> lus2lic4.sum <==
Test Run By jahier on Tue Sep 2 10:30:39
Test Run By jahier on Wed Sep 3 09:14:10
Native configuration is i686-pc-linux-gnu
=== lus2lic4 tests ===
......@@ -1502,7 +1505,7 @@ PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node test.lus {}
PASS: ./lus2lic {-o test_node_expand.lic test_node_expand.lus}
PASS: ./lus2lic {-ec -o test_node_expand.ec test_node_expand.lus}
PASS: ./myec2c {-o test_node_expand.c test_node_expand.ec}
FAIL: Try to compare lus2lic -exec and ecexe: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node test_node_expand.lus {}
PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node test_node_expand.lus {}
PASS: ./lus2lic {-o test_clash.lic test_clash.lus}
PASS: ./lus2lic {-ec -o test_clash.ec test_clash.lus}
PASS: ./myec2c {-o test_clash.c test_clash.ec}
......@@ -1625,7 +1628,10 @@ PASS: ./lus2lic {-o PCOND1.lic PCOND1.lus}
PASS: ./lus2lic {-ec -o PCOND1.ec PCOND1.lus}
PASS: ./myec2c {-o PCOND1.c PCOND1.ec}
PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node PCOND1.lus {}
FAIL: without any option: ./lus2lic {-o PCOND.lic PCOND.lus}
PASS: ./lus2lic {-o PCOND.lic PCOND.lus}
PASS: ./lus2lic {-ec -o PCOND.ec PCOND.lus}
PASS: ./myec2c {-o PCOND.c PCOND.ec}
FAIL: Try to compare lus2lic -exec and ecexe: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node PCOND.lus {}
PASS: ./lus2lic {-o SWITCH.lic SWITCH.lus}
PASS: ./lus2lic {-ec -o SWITCH.ec SWITCH.lus}
PASS: ./myec2c {-o SWITCH.c SWITCH.ec}
......@@ -1683,7 +1689,7 @@ PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node X.lus {}
=== lus2lic2 Summary ===
# of expected passes 304
# of expected passes 307
# of unexpected failures 2
==> lus2lic3.sum <==
......@@ -1697,18 +1703,18 @@ PASS: /home/jahier/lus2lic/test/../utils/test_lus2lic_no_node X.lus {}
=== lus2lic4 Summary ===
# of expected passes 431
# of unexpected failures 4
# of expected passes 435
# of unexpected failures 3
===============================
# Total number of failures: 23
lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in 1 seconds
lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 57 seconds
lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 87 seconds
lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 43 seconds
lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 103 seconds
# Total number of failures: 22
lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in 6 seconds
lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 75 seconds
lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 110 seconds
lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 72 seconds
lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 130 seconds
* Ref time:
0.10user 0.08system 3:18.04elapsed 0%CPU (0avgtext+0avgdata 2460maxresident)k
0inputs+0outputs (0major+12500minor)pagefaults 0swaps
0.11user 0.08system 3:14.15elapsed 0%CPU (0avgtext+0avgdata 2460maxresident)k
0inputs+0outputs (0major+12501minor)pagefaults 0swaps
* Quick time (-j 4):
0.07user 0.06system 1:44.70elapsed 0%CPU (0avgtext+0avgdata 2460maxresident)k
0inputs+0outputs (0major+12495minor)pagefaults 0swaps
0.07user 0.08system 2:22.70elapsed 0%CPU (0avgtext+0avgdata 2464maxresident)k
1696inputs+0outputs (4major+12518minor)pagefaults 0swaps
lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in 1 seconds
lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 57 seconds
lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 87 seconds
lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 43 seconds
lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 103 seconds
lus2lic0.log:testcase ./lus2lic.tests/test0.exp completed in 6 seconds
lus2lic1.log:testcase ./lus2lic.tests/test1.exp completed in 75 seconds
lus2lic2.log:testcase ./lus2lic.tests/test2.exp completed in 110 seconds
lus2lic3.log:testcase ./lus2lic.tests/test3.exp completed in 72 seconds
lus2lic4.log:testcase ./lus2lic.tests/test4.exp completed in 130 seconds
* Ref time:
0.10user 0.08system 3:18.04elapsed 0%CPU (0avgtext+0avgdata 2460maxresident)k
0inputs+0outputs (0major+12500minor)pagefaults 0swaps
0.11user 0.08system 3:14.15elapsed 0%CPU (0avgtext+0avgdata 2460maxresident)k
0inputs+0outputs (0major+12501minor)pagefaults 0swaps
* Quick time (-j 4):
0.07user 0.06system 1:44.70elapsed 0%CPU (0avgtext+0avgdata 2460maxresident)k
0inputs+0outputs (0major+12495minor)pagefaults 0swaps
0.07user 0.08system 2:22.70elapsed 0%CPU (0avgtext+0avgdata 2464maxresident)k
1696inputs+0outputs (4major+12518minor)pagefaults 0swaps
......@@ -10,19 +10,25 @@ returns (hX:bool; X:int);
var
hX1 : bool when h0;
X1 : int when hX1;
hA_when_h0,hB_when_h0,hC_when_h0 : bool when h0;
hD_when_hC_when_h0 : bool when hC_when_h0;
let
hX = current(hX1);
X = current(current(X1));
hA_when_h0 = hA when h0;
hB_when_h0 = hB when h0;
hC_when_h0 = hC when h0;
hD_when_hC_when_h0 = hD when hC_when_h0;
hX1, X1 = PCOND_clk(
h0,
hA when h0,
hA_when_h0,
hB when h0,
hC when h0,
A when hA,
B when hB,
C when hC,
hD when hC,
D when hD);
A when hA_when_h0,
B when hB_when_h0,
C when hC_when_h0,
hD when hC_when_h0,
D when hD_when_hC_when_h0);
tel
node PCOND_clk(
......
......@@ -3,7 +3,7 @@
* Failures spotted by non reg tests (26)
** TODO Front-end error (2)
** TODO Front-end error (1)
- State "TODO" from "" [2014-08-26 Tue 10:20]
cat lus2lic*.log | grep "FAIL: without any option:" | sed s/'FAIL: without any option:'/-/
......@@ -11,8 +11,6 @@
1. ./lus2lic -o bug_map_fby.lic bug_map_fby.lus
map<<fby, n>> pas supporté
2. ./lus2lic should_work/PCOND.lus -n PCOND
clock error.
** TODO soc2c (7)
- State "TODO" from "" [2014-08-26 Tue 10:20]
......@@ -46,12 +44,12 @@ cat lus2lic*.log | grep "FAIL: Generate c code :" | sed s/'FAIL: Generate c cod
cat lus2lic*.log | grep "FAIL: Try ec2c on the result:" | sed s/'FAIL: Try ec2c on the result:'/-/
1. ./myec2c {-o array_concat.c array_concat.ec}
2. ./myec2c {-o modes3x2_v4.c modes3x2_v4.ec}
3. ./myec2c {-o modes3x2_v3.c modes3x2_v3.ec}
4. ./myec2c {-o test_merge.c test_merge.ec}
1. ./myec2c -o array_concat.c array_concat.ec
2. ./myec2c -o modes3x2_v4.c modes3x2_v4.ec
3. ./myec2c -o modes3x2_v3.c modes3x2_v3.ec
4. ./myec2c -o test_merge.c test_merge.ec
** TODO Divergences -exec et ecexe (7)
** TODO Divergences -exec et ecexe (6)
- State "TODO" from "" [2014-07-11 Fri 16:54]
grep "FAIL:" lus2lic*.log | grep "exec" | grep "ecexe" | sed s/'FAIL: Try to compare lus2lic -exec and ecexe:'/-/
......@@ -60,30 +58,33 @@ cat lus2lic*.log | grep "FAIL: Generate c code :" | sed s/'FAIL: Generate c cod
-> ecexe : "#ERROR: Output takes on nil"
2) ../utils/test_lus2lic_no_node should_work/test_node_expand2.lus
3) ../utils/test_lus2lic_no_node should_work/test_node_expand.lus
4) ../utils/test_lus2lic_no_node should_work/filter.lus
5) ../utils/test_lus2lic_no_node should_work/multipar.lus
deja vu
int too big! (truncation error)
cf file:~/rdbg/src/localGenlex.ml
3) ../utils/test_lus2lic_no_node should_work/filter.lus
spurious cycle detected
4) ../utils/test_lus2lic_no_node should_work/multipar.lus
int too big! (truncation error)
6) ../utils/test_lus2lic_no_node should_work/Gyroscope.lus
5) ../utils/test_lus2lic_no_node should_work/Gyroscope.lus
#ERROR: Output takes on nil
7) ../utils/test_lus2lic_no_node should_work/cond01.lus
deja vu
6) ../utils/test_lus2lic_no_node should_work/cond01.lus
cf plus haut (polymorphisme et iterateur)
** TODO divergence -exec et -2c (3)
** TODO divergence -exec et -2c (2)
- State "TODO" from "" [2014-07-11 Fri 12:02]
grep "FAIL:" lus2lic*.log | grep "exec" | grep "\-2c" | sed s/'FAIL: Try to compare lus2lic -exec and -2c:'/-/
1. ../utils/compare_exec_and_2c should_work/test_node_expand2.lus 2000
-> -2110104000 est n'est pas un entier acceptable pour lutin sur les machines 32 bits...
int too big! (truncation error)
2. ../utils/compare_exec_and_2c should_work/test_node_expand.lus 2000
-> idem
2. ../utils/compare_exec_and_2c should_work/multipar.lus 2000
int too big! (truncation error)
3. ../utils/compare_exec_and_2c should_work/multipar.lus 2000
-> idem
* lus2lic -2C
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment