[PATCH] Fix gdb crash due to SIGPIPE when the compile command fails
Bernd Edlinger
bernd.edlinger@hotmail.de
Mon Jun 14 12:57:00 GMT 2021
Hi Rainer,
On 6/14/21 1:41 PM, Rainer Orth wrote:
> Hi Bernd,
>
>> On 6/4/21 3:39 PM, Tom Tromey wrote:
>>>>>>>> "Bernd" == Bernd Edlinger <bernd.edlinger@hotmail.de> writes:
>>>
>>> Bernd> I believe it is right to avoid the SIGPIPE before calling the plugin,
>>> Bernd> instead of doing that in gcc-trunk, since we don't know which version
>>> Bernd> we will be calling, and all versions I tried have failed like this.
>>>
>>> That seems fine, but I think it would be better to install the handler
>>> just when working with the plugin, and then uninstall it afterward, sort
>>> of like what class scoped_ignore_sigttou does.
>>>
>>
>> Okay, done, that works for me.
>>
>> Is this OK?
>
> this patch broke the Solaris build:
>
> /vol/src/gnu/gdb/hg/master/dist/gdb/compile/compile.c:659:3: error: ‘sighandler_t’ does not name a type; did you mean ‘sa_handler’?
> 659 | sighandler_t m_osigpipe = NULL;
> | ^~~~~~~~~~~~
> | sa_handler
> /vol/src/gnu/gdb/hg/master/dist/gdb/compile/compile.c: In constructor ‘scoped_ignore_sigpipe::scoped_ignore_sigpipe()’:
> /vol/src/gnu/gdb/hg/master/dist/gdb/compile/compile.c:644:5: error: ‘m_osigpipe’ was not declared in this scope
> 644 | m_osigpipe = signal (SIGPIPE, SIG_IGN);
> | ^~~~~~~~~~
> /vol/src/gnu/gdb/hg/master/dist/gdb/compile/compile.c:644:18: error: ‘signal’ was not declared in this scope; did you mean ‘sigval’?
> 644 | m_osigpipe = signal (SIGPIPE, SIG_IGN);
> | ^~~~~~
> | sigval
> /vol/src/gnu/gdb/hg/master/dist/gdb/compile/compile.c: In destructor ‘scoped_ignore_sigpipe::~scoped_ignore_sigpipe()’:
> /vol/src/gnu/gdb/hg/master/dist/gdb/compile/compile.c:651:22: error: ‘m_osigpipe’ was not declared in this scope
> 651 | signal (SIGPIPE, m_osigpipe);
> | ^~~~~~~~~~
> /vol/src/gnu/gdb/hg/master/dist/gdb/compile/compile.c:651:5: error: ‘signal’ was not declared in this scope; did you mean ‘sigval’?
> 651 | signal (SIGPIPE, m_osigpipe);
> | ^~~~~~
> | sigval
>
> and I have a very hard time deciding where <signal.h> needs to be
> included given the enormous range of headers included by compile.c.
>
Oh, I see, looks like it did only work by chance.
Maybe just include it after all other headers:
>From 6c6d25339460df2ad6eade17cc47a5e472208cc0 Mon Sep 17 00:00:00 2001
From: Bernd Edlinger <bernd.edlinger@hotmail.de>
Date: Mon, 14 Jun 2021 14:49:21 +0200
Subject: [PATCH] Include missing header signal.h
2021-06-14 Bernd Edlinger <bernd.edlinger@hotmail.de>
* compile/compile.c: Include missing header signal.h.
---
gdb/compile/compile.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index 8247fc4..abbb72a 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -43,6 +43,7 @@
#include "gdbsupport/gdb_optional.h"
#include "gdbsupport/gdb_unlinker.h"
#include "gdbsupport/pathstuff.h"
+#include <signal.h>
^L
--
1.9.1
I guess, I'll commit it as obvious, unless someone objects.
Thanks
Bernd.
More information about the Gdb-patches
mailing list