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

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