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] Fix crash in svr4_clear_so


Greetings,

Using current trunk, I've got a GDB core dump when I tried to analyze
mis-matched binary and core:

gdb a.out core
GNU gdb (GDB) 7.6.50.20130521-cvs
...
warning: core file may not match specified executable file.
[New LWP 29265]
...
[New LWP 27085]
[New LWP 27052]
warning: Error reading shared library list entry at 0x3b48104f8b480000
Segmentation fault

The actual crash is happening here:

Program received signal SIGSEGV, Segmentation fault.
0x0000000000481376 in svr4_clear_so (so=0xc833490) at ../../src/gdb/solib-svr4.c:974
974       so->lm_info->l_addr_p = 0;

#0  0x0000000000481376 in svr4_clear_so (so=0xc833490) at ../../src/gdb/solib-svr4.c:974
#1  0x0000000000708bc4 in clear_so (so=0xc833490) at ../../src/gdb/solib.c:537
#2  0x0000000000708bef in free_so (so=0xc833490) at ../../src/gdb/solib.c:556
#3  0x00000000006ee328 in do_free_so (arg=0xc833490) at ../../src/gdb/utils.c:492
#4  0x0000000000573474 in do_my_cleanups (pmy_chain=0xc5c1f0 <cleanup_chain>, old_chain=0x35232410) at ../../src/gdb/cleanups.c:155
#5  0x00000000005734e1 in do_cleanups (old_chain=0x35232410) at ../../src/gdb/cleanups.c:177
#6  0x00000000004817e0 in svr4_read_so_list (lm=4271682180386127872, link_ptr_ptr=0x7fff7fc37c58, ignore_first=1) at ../../src/gdb/solib-svr4.c:1195
#7  0x0000000000481b01 in svr4_current_sos () at ../../src/gdb/solib-svr4.c:1311
#8  0x0000000000708eea in update_solib_list (from_tty=0, target=0xc724c0 <core_ops>) at ../../src/gdb/solib.c:674
...

Attached patch fixes the GDB crash.

Ok for trunk?

Thanks,
--

2013-05-21  Paul Pluzhnikov  <ppluzhnikov@google.com>

	* solib-svr4.c (svr4_free_so): Protect against NULL dereference.


Index: solib-svr4.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-svr4.c,v
retrieving revision 1.177
diff -p -u -r1.177 solib-svr4.c
--- solib-svr4.c	6 May 2013 22:18:38 -0000	1.177
+++ solib-svr4.c	21 May 2013 22:19:09 -0000
@@ -971,7 +971,8 @@ svr4_free_so (struct so_list *so)
 static void
 svr4_clear_so (struct so_list *so)
 {
-  so->lm_info->l_addr_p = 0;
+  if (so->lm_info != NULL)
+    so->lm_info->l_addr_p = 0;
 }
 
 /* Free so_list built so far (called via cleanup).  */


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