Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Fix a crash in compile_to_object function
@ 2019-09-06 13:37 libor.bukata
  2019-09-06 16:42 ` Keith Seitz
  2019-09-09  8:07 ` Rainer Orth
  0 siblings, 2 replies; 7+ messages in thread
From: libor.bukata @ 2019-09-06 13:37 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 362 bytes --]

On non-Linux platforms, gdb crashes when compile command is issued
because of the null pointer in struct osabi_names gdb_osab. The attached
patch adds a check to avoid this crash and adds osabi name for Solaris.
However, there is probably more work required to enable compile feature
on Solaris (e.g., solaris_infcall_munmap) and other platforms.

Thanks,
Libor

[-- Attachment #2: 001-fix-null-ptr.patch --]
[-- Type: text/x-patch, Size: 1034 bytes --]

The patch fixes the crash on non-Linux platforms when
os_rx is a null pointer and converted to C++ std::string.

--- gdb-8.3/gdb/osabi.c	2019-08-19 11:15:04.176948730 +0000
+++ gdb-8.3/gdb/osabi.c	2019-08-19 11:13:43.202284584 +0000
@@ -63,7 +63,7 @@ static const struct osabi_names gdb_osab
 
   { "SVR4", NULL },
   { "GNU/Hurd", NULL },
-  { "Solaris", NULL },
+  { "Solaris", "solaris[2-9]\.[0-9][0-9]" },
   { "GNU/Linux", "linux(-gnu[^-]*)?" },
   { "FreeBSD", NULL },
   { "NetBSD", NULL },
--- gdb-8.3/gdb/compile/compile.c	2019-08-19 13:07:57.669785758 +0000
+++ gdb-8.3/gdb/compile/compile.c	2019-08-19 13:07:33.865626973 +0000
@@ -697,7 +697,7 @@ compile_to_object (struct command_line *
       const char *arch_rx = gdbarch_gnu_triplet_regexp (gdbarch);
 
       /* Allow triplets with or without vendor set.  */
-      triplet_rx = std::string (arch_rx) + "(-[^-]*)?-" + os_rx;
+      triplet_rx = std::string (arch_rx) + "(-[^-]*)?-" + (os_rx ? : "");
       compiler->set_triplet_regexp (triplet_rx.c_str ());
     }
 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-09-10  9:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-06 13:37 Fix a crash in compile_to_object function libor.bukata
2019-09-06 16:42 ` Keith Seitz
2019-09-06 17:11   ` libor.bukata
2019-09-09 17:56     ` Tom Tromey
2019-09-09  8:07 ` Rainer Orth
2019-09-09  8:57   ` libor.bukata
2019-09-10  9:18     ` Rainer Orth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox