This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH]13217 thread apply all detach throws a SEGFAULT


Hi,



I worked on bug#13217 "thread apply all detach throws a  SEGFAULT " of gdb

and fixed this problem by making a Patch.

I am upstreaming of it 



Actually when command "thread apply all detach" is applied then the function thread_apply_command (char *tidlist, int from_tty) in thread.c:1179 called a function init_thread_list (void)in thread.c:140

which makes the 'thread_list' struck to null so when for (tp = thread_list; tp; tp = tp->next) loop in thread_apply_command (char *tidlist, int from_tty) in thread.c:1179 iterates 2nd time it throws a segmentation fault when try to access the bogus value of
 thread_list

so i have fixed this problem

I have written the test case for it also

I have worked on gdb-7.5.50.20121127 snapshot



1) 

gdb/thread.c



diff -u  thread.c new_thread.c > change_thread.c

 ------------PATCH---------------------------------------

--- thread.c    2012-07-27 05:52:36.000000000 +0500

+++ new_thread.c    2013-01-02 12:06:51.876346782 +0500

@@ -1203,6 +1203,8 @@

     execute_command (cmd, from_tty);

     strcpy (cmd, saved_cmd);    /* Restore exact command used

                        previously.  */

+       if(thread_list == NULL)

+         break;

       }

 

   do_cleanups (old_chain);





2)

gdb/testsuit/gdb.thread

-----------------------------------test------------------------------------



--- threadapply.exp    2013-01-14 16:30:25.000000000 +0500

+++ new_threadapply.exp    2013-01-14 16:39:07.000000000 +0500

@@ -63,3 +63,4 @@

 gdb_test "up" ".*in main.*" "go up in the stack frame" 

 gdb_test "thread apply all print 1"  "Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1" "run a simple print command on all threads"

 gdb_test "down" "#0.*thread_function.*" "go down and check selected frame"

+gdb_test "thread apply all detach" "Thread.*\nDetaching from.*" "detaching from all threads"



------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



please review it and add me sourceware.org



thanks

Bilal











































 

 






Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]