Commit a65e7bfc authored by Hui Zhu's avatar Hui Zhu Committed by Linus Torvalds
Browse files

elf: fix multithreaded program core dumping on arm

Fix the multithread program core thread message error.

This issue affects arches with neither has CORE_DUMP_USE_REGSET nor
ELF_CORE_COPY_TASK_REGS, ARM is one of them.

The thread message of core file is generated in elf_dump_thread_status.
The register values is set by elf_core_copy_task_regs in this function.

If an arch doesn't define ELF_CORE_COPY_TASK_REGS,
elf_core_copy_task_regs() will do nothing.  Then the core file will not
have the register message of thread.

So add elf_core_copy_regs to set regiser values if ELF_CORE_COPY_TASK_REGS
doesn't define.

The following is how to reproduce this issue:

cat 1.c
#include <stdio.h>
#include <pthread.h>
#include <assert.h>

void td1(void * i)
       while (1)
               printf ("1\n");
               sleep (1);


void td2(void * i)
       while (1)
               printf ("2\n");
               sleep (1);


main(int argc,char *argv[],char *envp[])
       pthread_t       t1,t2;

       pthread_create(&t1, NULL, (void*)td1, NULL);
       pthread_create(&t2, NULL, (void*)td2, NULL);

       sleep (10);


       return (0);
arm-xxx-gcc -g -lpthread 1.c -o 1
copy 1.c and 1 to a arm board.
Goto this board.
ulimit -c 1800000
# ./1
1: 1.c:37: main: Assertion `0' failed.
Aborted (core dumped)
Then you can get a core file.
gdb 1
Without the patch:
(gdb) info threads
 3 process 909  0x00000000 in ?? ()
 2 process 908  0x00000000 in ?? ()
* 1 process 907  0x4a6e2238 in raise () from /lib/
You can found that the pc of 909 and 908 is 0x00000000.
With the patch:
(gdb) info threads
 3 process 885  0x4a749974 in nanosleep () from /lib/
 2 process 884  0x4a749974 in nanosleep () from /lib/
* 1 process 883  0x4a6e2238 in raise () from /lib/
The pc of 885 and 884 is right.

Signed-off-by: default avatarHui Zhu <>
Cc: Amerigo Wang <>
Cc: Al Viro <>
Cc: David Howells <>
Cc: Roland McGrath <>
Cc: Jakub Jelinek <>
Cc: Russell King <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 3beab0b4
......@@ -125,6 +125,8 @@ static inline int elf_core_copy_task_regs(struct task_struct *t, elf_gregset_t*
return ELF_CORE_COPY_TASK_REGS(t, elfregs);
elf_core_copy_regs(elfregs, task_pt_regs(t));
return 0;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment