Blame SOURCES/0017-Fix-task-R-by-adding-end-identifier-for-union-in-tas.patch

acf3ec
From c32abfea658ef33c20a942700277cb52baf95bfa Mon Sep 17 00:00:00 2001
acf3ec
From: Tao Liu <ltao@redhat.com>
acf3ec
Date: Thu, 25 Aug 2022 14:39:44 +0800
acf3ec
Subject: [PATCH 17/28] Fix "task -R" by adding end identifier for union in
acf3ec
 task_struct
acf3ec
acf3ec
Previously, the start and end identifiers for union are "  {\n" and
acf3ec
"  }, \n".  However the end identifier is not always as expected.
acf3ec
"  },\n" can also be the end identifier with gdb-10.2.  As a result,
acf3ec
variable "randomized" is in incorrect state after union, and fails to
acf3ec
identify the later struct members.  For example, we can reproduce the
acf3ec
issue as follows:
acf3ec
acf3ec
    crash> task
acf3ec
    PID: 847      TASK: ffff94f8038f4000  CPU: 72   COMMAND: "khungtaskd"
acf3ec
    struct task_struct {
acf3ec
      thread_info = {
acf3ec
	flags = 2148024320,
acf3ec
	status = 0,
acf3ec
	preempt_lazy_count = 0
acf3ec
      },
acf3ec
      {
acf3ec
	<the union>
acf3ec
      },
acf3ec
      ...
acf3ec
      wake_entry = {
acf3ec
	next = 0x0
acf3ec
      },
acf3ec
      ...
acf3ec
acf3ec
Before patch:
acf3ec
acf3ec
    crash> task -R wake_entry
acf3ec
    PID: 847      TASK: ffff94f8038f4000  CPU: 72   COMMAND: "khungtaskd"
acf3ec
acf3ec
After patch:
acf3ec
acf3ec
    crash> task -R wake_entry
acf3ec
    PID: 847      TASK: ffff94f8038f4000  CPU: 72   COMMAND: "khungtaskd"
acf3ec
      wake_entry = {
acf3ec
	next = 0x0
acf3ec
      },
acf3ec
acf3ec
Signed-off-by: Tao Liu <ltao@redhat.com>
acf3ec
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
acf3ec
---
acf3ec
 task.c | 3 ++-
acf3ec
 1 file changed, 2 insertions(+), 1 deletion(-)
acf3ec
acf3ec
diff --git a/task.c b/task.c
acf3ec
index 071c787fbfa5..db2abc8106a2 100644
acf3ec
--- a/task.c
acf3ec
+++ b/task.c
acf3ec
@@ -3436,7 +3436,8 @@ parse_task_thread(int argcnt, char *arglist[], struct task_context *tc) {
acf3ec
         while (fgets(buf, BUFSIZE, pc->tmpfile)) {
acf3ec
 		if (STREQ(buf, "  {\n"))
acf3ec
 			randomized = TRUE;
acf3ec
-		else if (randomized && STREQ(buf, "  }, \n"))
acf3ec
+		else if (randomized &&
acf3ec
+			 (STREQ(buf, "  }, \n") || STREQ(buf, "  },\n")))
acf3ec
 			randomized = FALSE;
acf3ec
 
acf3ec
 		if (strlen(lookfor2)) {
acf3ec
-- 
acf3ec
2.37.1
acf3ec