Coccinelle archive on lore.kernel.org
 help / color / Atom feed
* [Cocci] [PATCH 0/2] cocci: Fix continue statement of death and similar cases
@ 2019-11-27 17:38 Jaskaran Singh
  2019-11-27 17:38 ` [Cocci] [PATCH 1/2] engine: remove circular references in MINUS/NOREPLACEMENT case Jaskaran Singh
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jaskaran Singh @ 2019-11-27 17:38 UTC (permalink / raw)
  To: cocci; +Cc: linux-kernel-mentees, skhan

The following patch series is for fixing the "continue statement of
death" report here:

https://www.mail-archive.com/cocci@systeme.lip6.fr/msg06199.html

Changes include removing circular references that cause the crash
and adding a corresponding test case.

 engine/transformation_c.ml         |    2 +-
 tests/stmt_removed_and_added.c     |    8 ++++++++
 tests/stmt_removed_and_added.cocci |    7 +++++++
 tests/stmt_removed_and_added.res   |    8 ++++++++
 4 files changed, 24 insertions(+), 1 deletion(-)


_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* [Cocci] [PATCH 1/2] engine: remove circular references in MINUS/NOREPLACEMENT case
  2019-11-27 17:38 [Cocci] [PATCH 0/2] cocci: Fix continue statement of death and similar cases Jaskaran Singh
@ 2019-11-27 17:38 ` Jaskaran Singh
  2019-11-27 20:41   ` Markus Elfring
  2019-11-27 17:38 ` [Cocci] [PATCH 2/2] tests: Add test case for statement removed and added Jaskaran Singh
  2019-11-27 20:43 ` [Cocci] [PATCH 0/2] cocci: Fix continue statement of death and similar cases Julia Lawall
  2 siblings, 1 reply; 5+ messages in thread
From: Jaskaran Singh @ 2019-11-27 17:38 UTC (permalink / raw)
  To: cocci; +Cc: linux-kernel-mentees, skhan

The cocci info tag can sometimes have circular references in the
MINUS/NOREPLACEMENT case in the transformation. Pass the binding
info through clean_env to remove circular references.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 engine/transformation_c.ml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/engine/transformation_c.ml b/engine/transformation_c.ml
index bcde08b8..9f0b0ab2 100644
--- a/engine/transformation_c.ml
+++ b/engine/transformation_c.ml
@@ -380,7 +380,7 @@ module XTRANS = struct
 	  (Ast_cocci.MINUS
 	     (old_pos,Common.union_set old_inst new_inst,old_adj,
 	      Ast_cocci.NOREPLACEMENT),
-	   [tin.binding]);
+	   [clean_env tin.binding]);
         (if !Flag_matcher.show_misc
         then pr2_once "already tagged but only removed, so safe")
 
-- 
2.21.0

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* [Cocci] [PATCH 2/2] tests: Add test case for statement removed and added
  2019-11-27 17:38 [Cocci] [PATCH 0/2] cocci: Fix continue statement of death and similar cases Jaskaran Singh
  2019-11-27 17:38 ` [Cocci] [PATCH 1/2] engine: remove circular references in MINUS/NOREPLACEMENT case Jaskaran Singh
@ 2019-11-27 17:38 ` Jaskaran Singh
  2019-11-27 20:43 ` [Cocci] [PATCH 0/2] cocci: Fix continue statement of death and similar cases Julia Lawall
  2 siblings, 0 replies; 5+ messages in thread
From: Jaskaran Singh @ 2019-11-27 17:38 UTC (permalink / raw)
  To: cocci; +Cc: linux-kernel-mentees, skhan

This is in response to the following "continue statement of death"
report:

https://www.mail-archive.com/cocci@systeme.lip6.fr/msg06199.html

Coccinelle would crash in similar cases, so add a test case for it.

Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
---
 tests/stmt_removed_and_added.c     | 8 ++++++++
 tests/stmt_removed_and_added.cocci | 7 +++++++
 tests/stmt_removed_and_added.res   | 8 ++++++++
 3 files changed, 23 insertions(+)
 create mode 100644 tests/stmt_removed_and_added.c
 create mode 100644 tests/stmt_removed_and_added.cocci
 create mode 100644 tests/stmt_removed_and_added.res

diff --git a/tests/stmt_removed_and_added.c b/tests/stmt_removed_and_added.c
new file mode 100644
index 00000000..cbc64f42
--- /dev/null
+++ b/tests/stmt_removed_and_added.c
@@ -0,0 +1,8 @@
+void main()
+{
+	for(i; j; k) {
+		if (1)
+			continue;
+		c++;
+	}
+}
diff --git a/tests/stmt_removed_and_added.cocci b/tests/stmt_removed_and_added.cocci
new file mode 100644
index 00000000..93558a19
--- /dev/null
+++ b/tests/stmt_removed_and_added.cocci
@@ -0,0 +1,7 @@
+@@
+expression I, J, K;
+statement S;
+@@
+
+- for (I; J; K) S
++ while(1) S
diff --git a/tests/stmt_removed_and_added.res b/tests/stmt_removed_and_added.res
new file mode 100644
index 00000000..4b20027a
--- /dev/null
+++ b/tests/stmt_removed_and_added.res
@@ -0,0 +1,8 @@
+void main()
+{
+	while (1) {
+		if (1)
+			continue;
+		c++;
+	}
+}
-- 
2.21.0

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] [PATCH 1/2] engine: remove circular references in MINUS/NOREPLACEMENT case
  2019-11-27 17:38 ` [Cocci] [PATCH 1/2] engine: remove circular references in MINUS/NOREPLACEMENT case Jaskaran Singh
@ 2019-11-27 20:41   ` Markus Elfring
  0 siblings, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2019-11-27 20:41 UTC (permalink / raw)
  To: Jaskaran Singh, cocci; +Cc: linux-kernel-mentees, Shuah Khan

Thanks for your patch.


> The cocci info tag can sometimes have circular references in the
> MINUS/NOREPLACEMENT case in the transformation.

Can it make sense to clarify this software situation a bit more?


> Pass the binding info through clean_env to remove circular references.

Can such an additional function call be eventually avoided?

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] [PATCH 0/2] cocci: Fix continue statement of death and similar cases
  2019-11-27 17:38 [Cocci] [PATCH 0/2] cocci: Fix continue statement of death and similar cases Jaskaran Singh
  2019-11-27 17:38 ` [Cocci] [PATCH 1/2] engine: remove circular references in MINUS/NOREPLACEMENT case Jaskaran Singh
  2019-11-27 17:38 ` [Cocci] [PATCH 2/2] tests: Add test case for statement removed and added Jaskaran Singh
@ 2019-11-27 20:43 ` Julia Lawall
  2 siblings, 0 replies; 5+ messages in thread
From: Julia Lawall @ 2019-11-27 20:43 UTC (permalink / raw)
  To: Jaskaran Singh; +Cc: linux-kernel-mentees, cocci, skhan



--- Please note the new email address ---


On Wed, 27 Nov 2019, Jaskaran Singh wrote:

> The following patch series is for fixing the "continue statement of
> death" report here:
>
> https://www.mail-archive.com/cocci@systeme.lip6.fr/msg06199.html
>
> Changes include removing circular references that cause the crash
> and adding a corresponding test case.

Applied, thanks.

julia

>
>  engine/transformation_c.ml         |    2 +-
>  tests/stmt_removed_and_added.c     |    8 ++++++++
>  tests/stmt_removed_and_added.cocci |    7 +++++++
>  tests/stmt_removed_and_added.res   |    8 ++++++++
>  4 files changed, 24 insertions(+), 1 deletion(-)
>
>
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-27 17:38 [Cocci] [PATCH 0/2] cocci: Fix continue statement of death and similar cases Jaskaran Singh
2019-11-27 17:38 ` [Cocci] [PATCH 1/2] engine: remove circular references in MINUS/NOREPLACEMENT case Jaskaran Singh
2019-11-27 20:41   ` Markus Elfring
2019-11-27 17:38 ` [Cocci] [PATCH 2/2] tests: Add test case for statement removed and added Jaskaran Singh
2019-11-27 20:43 ` [Cocci] [PATCH 0/2] cocci: Fix continue statement of death and similar cases Julia Lawall

Coccinelle archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/cocci/0 cocci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cocci cocci/ https://lore.kernel.org/cocci \
		cocci@systeme.lip6.fr
	public-inbox-index cocci

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/fr.lip6.systeme.cocci


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git