crash icon indicating copy to clipboard operation
crash copied to clipboard

the union command sometimes can't works

Open prettykernel opened this issue 4 years ago • 4 comments


# crash /usr/lib/debug/usr/lib/modules/5.7.9-200.fc32.x86_64/vmlinux
crash 7.2.8-2.fc32

crash> union bpf_attr    // works well 
crash> bpf_attr
crash> *bpf_attr 

crash> union thread_union
union: invalid data structure reference: thread_union

crash> union thread_union init_thread_union
union: invalid data structure reference: thread_union

crash> thread_union
crash: command not found: thread_union

crash> *thread_union
*: invalid data structure reference: thread_union


// include/linux/sched.h
union thread_union {
#ifndef CONFIG_ARCH_TASK_STRUCT_ON_STACK
	struct task_struct task;
#endif
#ifndef CONFIG_THREAD_INFO_IN_TASK
	struct thread_info thread_info;
#endif
	unsigned long stack[THREAD_SIZE/sizeof(long)];
};

#grep CONFIG_ARCH_TASK_STRUCT_ON_STACK /boot/config-`uname -r`

#grep CONFIG_THREAD_INFO_IN_TASK /boot/config-`uname -r`
CONFIG_THREAD_INFO_IN_TASK=y

//include/asm-generic/vmlinux.lds.h
#define INIT_TASK_DATA(align)						\
	. = ALIGN(align);						\
	__start_init_task = .;						\
	init_thread_union = .;						\
	init_stack = .;							\
	KEEP(*(.data..init_task))					\
	KEEP(*(.data..init_thread_info))				\
	. = __start_init_task + THREAD_SIZE;				\
	__end_init_task = .;

crash> sym init_thread_union
ffffffff8f800000 (D) init_thread_union
crash> sym init_stack
ffffffff8f800000 (D) init_stack

prettykernel avatar Jul 24 '20 08:07 prettykernel

Hmm, is there the debug info for union thread_union in the vmlinux?

$ gdb /usr/lib/debug/lib/modules/4.18.0-193.el8.x86_64/vmlinux
...
(gdb) info types thread_union
All types matching regular expression "thread_union":

File ./include/linux/sched.h:
1619:   union thread_union;
(gdb) ptype init_thread_union
type = union thread_union {
    struct task_struct task;
    unsigned long stack[2048];
}
(gdb)

k-hagio avatar Jul 29 '20 06:07 k-hagio

Hi, it can't work in Fedora 32, but it works well in Ubuntu 18.04/20.04 and CentOS 8, 
and the definition of thread_union are the same in kernel v4.18 and v5.7.9.

Why there is no debug info for thread_union ?

#gdb /usr/lib/debug/lib/modules/5.7.9-200.fc32.x86_64/vmlinux
GNU gdb (GDB) Fedora 9.1-5.fc32
Reading symbols from /usr/lib/debug/lib/modules/5.7.9-200.fc32.x86_64/vmlinux...
(gdb) info types thread_union
All types matching regular expression "thread_union":
(gdb) ptype init_thread_union
type = <data variable, no debug info>


#crash /usr/lib/debug/usr/lib/modules/5.7.9-200.fc32.x86_64/vmlinux
crash 7.2.8-2.fc32
GNU gdb (GDB) 7.6
This GDB was configured as "x86_64-unknown-linux-gnu"...
crash> i ty thread_union
All types matching regular expression "thread_union":
crash> ptype init_thread_union
type = <data variable, no debug info>

prettykernel avatar Aug 03 '20 05:08 prettykernel

Why there is no debug info for thread_union ?

I'm not sure. Fedora kernel team might know about it, could you ask them?

@bhupesh-sharma, @lian-bo FYI. I hope that future RHEL kernels won't have the same phenomenon..

k-hagio avatar Aug 03 '20 07:08 k-hagio

Just a note, found a couple of threads related to this phenomenon in the mail list: https://www.redhat.com/archives/crash-utility/2018-April/msg00004.html https://www.redhat.com/archives/crash-utility/2018-April/msg00010.html

k-hagio avatar Aug 20 '20 02:08 k-hagio