"badly compiled mcode" error
Hello,
While testing a larger semantic patch I came across the following error:
"""init_defs_builtins: /usr/share/coccinelle/standard.h Fatal error: exception Failure("badly compiled mcode") """
Here, I can reproduce it by running spatch --parse-cocci on the attached test.cocci.
$ spatch --version spatch version 1.0.0-rc21 with Python support and with PCRE support
Thanks,
riccardo
-------------- next part --------------
@@
identifier func;
expression e,el,er;
statement S;
@@
func(...) {
- if (el - e - er) S
}
Quoted 9 lines · Riccardo Lucchese
Hello,
While testing a larger semantic patch I came across the following error:
"""init_defs_builtins:/usr/share/coccinelle/standard.hFatal error: exceptionFailure("badly compiled mcode")"""
Quoted 5 lines
Here, I can reproduce it by running spatch --parse-cocci on the attached
test.cocci.$ spatch --version spatch version 1.0.0-rc21 with Python support and with PCRE support
I can indeed reproduce it, although I have never seen that before. I will look into it tomorrow. You can avoid the problem by disabling isomorphisms, eg --iso-file empty.iso where empty.iso is an empty file. But maybe you need isomorphisms for another rule...
julia
A patch is below.
julia
parsing_cocci/iso_compile.ml +8 -7
@@ -52,7 +52,7 @@ let process_info l = let safe_add p pos = (* don't add pos var where a pos var is already present *) if Common.inter_set previously_used pos = [] then p::pos else pos in - let p = + let new_previously_used = if List.for_all (List.for_all (function e -> List.length e = 1)) a then let p = get_p() in
@@ -60,22 +60,23 @@ let process_info l = (List.iter (List.iter (function (_,pos) -> pos := safe_add p !pos))) a; - [p] + p::previously_used else let all = r @ List.concat xs in - let rec find_first_available a = function + let rec find_first_available a previously_used = function [] -> raise Not_found | (str,pos)::xs -> if str = a && Common.inter_set previously_used !pos = [] then pos - else find_first_available a xs in + else find_first_available a previously_used xs in List.fold_left (function prev -> function (str,pos) -> if Common.inter_set previously_used !pos = [] then try - let entries = List.map (find_first_available str) all in + let entries = + List.map (find_first_available str prev) all in let p = get_p() in pos := p::!pos; List.iter (function pos -> pos := p :: !pos) entries;
@@ -83,8 +84,8 @@ let process_info l = with Not_found -> prev (* otherwise already annotated *) else prev) - [] f in - loop (p at previously_used) xs + previously_used f in + loop new_previously_used xs | _ -> failwith "bad iso" in loop l
Quoted 3 lines · Julia Lawall
A patch is below.
julia
Thank you, I cannot reproduce the error with this applied.
riccardo
Quoted 52 lines
parsing_cocci/iso_compile.ml +8
-7@@ -52,7 +52,7 @@ let process_info l = let safe_add p pos = (* don't add pos var where a pos var is already present *) if Common.inter_set previously_used pos = [] then p::pos else pos in - let p = + let new_previously_used = if List.for_all (List.for_all (function e -> List.length e = 1)) a then let p = get_p() in@@ -60,22 +60,23 @@ let process_info l = (List.iter (List.iter (function (_,pos) -> pos := safe_add p !pos))) a; - [p] + p::previously_used else let all = r @ List.concat xs in - let rec find_first_available a = function + let rec find_first_available a previously_used = function [] -> raise Not_found | (str,pos)::xs -> if str = a && Common.inter_set previously_used !pos = [] then pos - else find_first_available a xs in + else find_first_available a previously_used xs in List.fold_left (function prev -> function (str,pos) -> if Common.inter_set previously_used !pos = [] then try - let entries = List.map (find_first_available str) all in + let entries = + List.map (find_first_available str prev) all in let p = get_p() in pos := p::!pos; List.iter (function pos -> pos := p :: !pos) entries;@@ -83,8 +84,8 @@ let process_info l = with Not_found -> prev (* otherwise already annotated *) else prev) - [] f in - loop (p at previously_used) xs + previously_used f in + loop new_previously_used xs | _ -> failwith "bad iso" in loop l