]> git.pld-linux.org Git - packages/gdb.git/blob - gdb-core-thread-internalerr-2of3.patch
- up to 7.3.1
[packages/gdb.git] / gdb-core-thread-internalerr-2of3.patch
1 http://sourceware.org/ml/gdb-patches/2011-02/msg00680.html
2 Subject: [patch 2/3] Fix threading internal error on corrupted memory [rediff]
3
4 [rediff]
5
6 gdb/
7 2011-02-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
8
9         * linux-thread-db.c (find_new_threads_callback): Exit on zero TI_TID
10         even if !TARGET_HAS_EXECUTION.
11
12 gdb/testsuite/
13 2011-02-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
14
15         * gdb.threads/gcore-thread.exp ($core0file): New variable.
16         (clear __stack_user.next, clear stack_used.next)
17         (save a zeroed-threads corefile): New test.
18         Call core_load for $core0file.
19         (zeroed-threads cannot be listed): New test.
20
21 --- a/gdb/linux-thread-db.c
22 +++ b/gdb/linux-thread-db.c
23 @@ -1335,7 +1335,7 @@ find_new_threads_callback (const td_thrhandle_t *th_p, void *data)
24    if (ti.ti_state == TD_THR_UNKNOWN || ti.ti_state == TD_THR_ZOMBIE)
25      return 0;                  /* A zombie -- ignore.  */
26  
27 -  if (ti.ti_tid == 0 && target_has_execution)
28 +  if (ti.ti_tid == 0)
29      {
30        /* A thread ID of zero means that this is the main thread, but
31          glibc has not yet initialized thread-local storage and the
32 @@ -1347,10 +1347,13 @@ find_new_threads_callback (const td_thrhandle_t *th_p, void *data)
33          need this glibc bug workaround.  */
34        info->need_stale_parent_threads_check = 0;
35  
36 -      err = info->td_thr_event_enable_p (th_p, 1);
37 -      if (err != TD_OK)
38 -       error (_("Cannot enable thread event reporting for LWP %d: %s"),
39 -              (int) ti.ti_lid, thread_db_err_str (err));
40 +      if (target_has_execution)
41 +       {
42 +         err = info->td_thr_event_enable_p (th_p, 1);
43 +         if (err != TD_OK)
44 +           error (_("Cannot enable thread event reporting for LWP %d: %s"),
45 +                  (int) ti.ti_lid, thread_db_err_str (err));
46 +       }
47  
48        return 0;
49      }
50 --- a/gdb/testsuite/gdb.threads/gcore-thread.exp
51 +++ b/gdb/testsuite/gdb.threads/gcore-thread.exp
52 @@ -26,6 +26,7 @@ set testfile "gcore-thread"
53  set srcfile  pthreads.c
54  set binfile  ${objdir}/${subdir}/${testfile}
55  set corefile ${objdir}/${subdir}/${testfile}.test
56 +set core0file ${objdir}/${subdir}/${testfile}0.test
57  
58  if [istarget "*-*-linux"] then {
59      set target_cflags "-D_MIT_POSIX_THREADS"
60 @@ -110,6 +111,29 @@ if {!$core_supported} {
61  }
62  
63  
64 +# Test the uninitialized thread list.
65 +# Provide the case of glibc td_thr_get_info handling of:
66 +# /* Special case for the main thread before initialization.  */
67 +
68 +foreach symbol {__stack_user stack_used} {
69 +    set test "clear ${symbol}.next"
70 +    gdb_test_multiple "p *(void **) &${symbol} = 0" $test {
71 +       -re " = \\(void \\*\\) 0x0\r\n$gdb_prompt $" {
72 +           pass $test
73 +       }
74 +       -re "No symbol \"${symbol}\" in current context\\.\r\n$gdb_prompt $" {
75 +           xfail $test
76 +           # Do not do the verification.
77 +           set core0file ""
78 +       }
79 +    }
80 +}
81 +
82 +if {"$core0file" != ""} {
83 +    gdb_test "gcore $core0file" "Saved corefile .*" "save a zeroed-threads corefile"
84 +}
85 +
86 +
87  # Now restart gdb and load the corefile.
88  clean_restart ${testfile}
89  
90 @@ -160,3 +184,11 @@ gdb_test "info threads" ".* thread2 .*" \
91  
92  gdb_test "info threads" ".*${nl}\\* ${horiz} thread2 .*" \
93         "thread2 is current thread in corefile"
94 +
95 +
96 +# Test the uninitialized thread list.
97 +
98 +if {"$core0file" != "" && [load_core $core0file]} {
99 +
100 +    gdb_test "info threads" "Cannot find new threads: .*" "zeroed-threads cannot be listed"
101 +}
102
This page took 0.840889 seconds and 4 git commands to generate.