linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
* [Linux-kernel-mentees] [PATCH 0/2] cocci: Fix continue statement of death and similar cases
@ 2019-11-27 17:38 Jaskaran Singh
  2019-11-27 17:38 ` [Linux-kernel-mentees] [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: julia.lawall, linux-kernel-mentees

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(-)


_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* [Linux-kernel-mentees] [PATCH 1/2] engine: remove circular references in MINUS/NOREPLACEMENT case
  2019-11-27 17:38 [Linux-kernel-mentees] [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 ` [Linux-kernel-mentees] [PATCH 2/2] tests: Add test case for statement removed and added Jaskaran Singh
  2019-11-27 20:43 ` [Linux-kernel-mentees] [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: julia.lawall, linux-kernel-mentees

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

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* [Linux-kernel-mentees] [PATCH 2/2] tests: Add test case for statement removed and added
  2019-11-27 17:38 [Linux-kernel-mentees] [PATCH 0/2] cocci: Fix continue statement of death and similar cases Jaskaran Singh
  2019-11-27 17:38 ` [Linux-kernel-mentees] [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 ` [Linux-kernel-mentees] [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: julia.lawall, linux-kernel-mentees

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

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* Re: [Linux-kernel-mentees] [PATCH 1/2] engine: remove circular references in MINUS/NOREPLACEMENT case
  2019-11-27 17:38 ` [Linux-kernel-mentees] [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

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
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* Re: [Linux-kernel-mentees] [PATCH 0/2] cocci: Fix continue statement of death and similar cases
  2019-11-27 17:38 [Linux-kernel-mentees] [PATCH 0/2] cocci: Fix continue statement of death and similar cases Jaskaran Singh
  2019-11-27 17:38 ` [Linux-kernel-mentees] [PATCH 1/2] engine: remove circular references in MINUS/NOREPLACEMENT case Jaskaran Singh
  2019-11-27 17:38 ` [Linux-kernel-mentees] [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



--- 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(-)
>
>
>
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

end of thread, other threads:[~2019-11-27 20:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-27 17:38 [Linux-kernel-mentees] [PATCH 0/2] cocci: Fix continue statement of death and similar cases Jaskaran Singh
2019-11-27 17:38 ` [Linux-kernel-mentees] [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 ` [Linux-kernel-mentees] [PATCH 2/2] tests: Add test case for statement removed and added Jaskaran Singh
2019-11-27 20:43 ` [Linux-kernel-mentees] [PATCH 0/2] cocci: Fix continue statement of death and similar cases Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).