All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cocci] [bug-cocci] "badly compiled mcode" error
@ 2014-07-21 18:42 Riccardo Lucchese
  2014-07-21 19:47 ` Julia Lawall
  2014-07-22 12:55 ` Julia Lawall
  0 siblings, 2 replies; 4+ messages in thread
From: Riccardo Lucchese @ 2014-07-21 18:42 UTC (permalink / raw)
  To: cocci

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
}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Cocci] [bug-cocci] "badly compiled mcode" error
  2014-07-21 18:42 [Cocci] [bug-cocci] "badly compiled mcode" error Riccardo Lucchese
@ 2014-07-21 19:47 ` Julia Lawall
  2014-07-22 12:55 ` Julia Lawall
  1 sibling, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2014-07-21 19:47 UTC (permalink / raw)
  To: cocci

On Mon, 21 Jul 2014, Riccardo Lucchese wrote:

> 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

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Cocci] [bug-cocci] "badly compiled mcode" error
  2014-07-21 18:42 [Cocci] [bug-cocci] "badly compiled mcode" error Riccardo Lucchese
  2014-07-21 19:47 ` Julia Lawall
@ 2014-07-22 12:55 ` Julia Lawall
  2014-07-22 13:43   ` Riccardo Lucchese
  1 sibling, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2014-07-22 12:55 UTC (permalink / raw)
  To: cocci

A patch is below.

julia

diff --git a/parsing_cocci/iso_compile.ml b/parsing_cocci/iso_compile.ml
index 5e39b9c..7921f44 100644
--- a/parsing_cocci/iso_compile.ml
+++ b/parsing_cocci/iso_compile.ml
@@ -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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Cocci] [bug-cocci] "badly compiled mcode" error
  2014-07-22 12:55 ` Julia Lawall
@ 2014-07-22 13:43   ` Riccardo Lucchese
  0 siblings, 0 replies; 4+ messages in thread
From: Riccardo Lucchese @ 2014-07-22 13:43 UTC (permalink / raw)
  To: cocci

On Tue, Jul 22, 2014 at 02:55:57PM +0200, Julia Lawall wrote:
> A patch is below.
> 
> julia

Thank you, I cannot reproduce the error with this applied.

riccardo


> diff --git a/parsing_cocci/iso_compile.ml b/parsing_cocci/iso_compile.ml
> index 5e39b9c..7921f44 100644
> --- a/parsing_cocci/iso_compile.ml
> +++ b/parsing_cocci/iso_compile.ml
> @@ -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
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-07-22 13:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-21 18:42 [Cocci] [bug-cocci] "badly compiled mcode" error Riccardo Lucchese
2014-07-21 19:47 ` Julia Lawall
2014-07-22 12:55 ` Julia Lawall
2014-07-22 13:43   ` Riccardo Lucchese

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.