On 2022/08/25 15:39, Tao Liu wrote:
 Previously, the start and end identifier for union is " 
{\n"
 and "  }, \n". However the end identifier is not always as
 expected. "  },\n" can also be the end identifier. As a result,
 variable "randomized" is in incorrect state after union, and
 fails to identify the later struct members. For example, we can
 reproduce the issue as follows:
 
      crash> task
      PID: 847      TASK: ffff94f8038f4000  CPU: 72   COMMAND: "khungtaskd"
      struct task_struct {
        thread_info = {
 	flags = 2148024320,
 	status = 0,
 	preempt_lazy_count = 0
        },
        {
 	<the union>
        },
        ...
        wake_entry = {
 	next = 0x0
        },
        ...
 
 Before patch:
 
      crash> task -R wake_entry
      PID: 847      TASK: ffff94f8038f4000  CPU: 72   COMMAND: "khungtaskd"
 
 After patch:
 
      crash> task -R wake_entry
      PID: 847      TASK: ffff94f8038f4000  CPU: 72   COMMAND: "khungtaskd"
        wake_entry = {
 	next = 0x0
        },
 
 Signed-off-by: Tao Liu <ltao(a)redhat.com>
 ---
 
 v1 -> v2: Rewrite the commit log.
 
Thanks for the update.
I will add "with gdb-10.2" to the commit log when applying.
Acked-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
Thanks,
Kazu
> 
> ---
>   task.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/task.c b/task.c
> index 071c787..db2abc8 100644
> --- a/task.c
> +++ b/task.c
> @@ -3436,7 +3436,8 @@ parse_task_thread(int argcnt, char *arglist[], struct
task_context *tc) {
>           while (fgets(buf, BUFSIZE, pc->tmpfile)) {
>   		if (STREQ(buf, "  {\n"))
>   			randomized = TRUE;
> -		else if (randomized && STREQ(buf, "  }, \n"))
> +		else if (randomized &&
> +			 (STREQ(buf, "  }, \n") || STREQ(buf, "  },\n")))
>   			randomized = FALSE;
>   
>   		if (strlen(lookfor2)) {