* [RFA] gdbserver crash in gdb/gdbserver/thread.c::thread_search_callback
@ 2015-12-21 15:15 Joel Brobecker
2015-12-21 16:53 ` Pedro Alves
0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2015-12-21 15:15 UTC (permalink / raw)
To: gdb-patches; +Cc: Pedro Alves
Connecting GDB to a LynxOS-178 GDBserver causes GDBserver to crash:
% gdbserver :4444 simple_main
Process simple_main created; pid = 19
Listening on port 4444
Remote debugging from host 205.232.38.10
Segmentation fault (core dumped)
We saw this crash on LynxOS and also when using GDBserver on Windows.
The crash happens in thread_search_callback where the function
calls the_target->thread_stopped (via the thread_stopped macro)
without verifying whether the callback is NULL or not.
For the record, the regression was introduced by:
commit a67a9faef0e32886c83611cc7a0ba61e91123063
Date: Mon Nov 30 16:05:26 2015 +0000
Subject: gdbserver:prepare_access_memory: pick another thread
This patch avoids the crash by checking the value of the callback
first, before calling it.
gdb/gdbserver/ChangeLog:
* target.c (thread_search_callback): Add check that
the thread_stopped target callback is not NULL before
calling it.
Does the fix look good to you?
Tested on both Windows (native gdbserver) and LynxOS using
AdaCore's gdb-testsuite.
Thanks,
--
Joel
---
gdb/gdbserver/target.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gdb/gdbserver/target.c b/gdb/gdbserver/target.c
index b376ce8..59736e5 100644
--- a/gdb/gdbserver/target.c
+++ b/gdb/gdbserver/target.c
@@ -68,7 +68,9 @@ thread_search_callback (struct inferior_list_entry *entry, void *args)
if (ptid_get_pid (entry->id) == ptid_get_pid (s->current_gen_ptid)
&& mythread_alive (ptid_of (thread)))
{
- if (s->stopped == NULL && thread_stopped (thread))
+ if (s->stopped == NULL
+ && the_target->thread_stopped != NULL
+ && thread_stopped (thread))
s->stopped = thread;
if (s->first == NULL)
--
2.1.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA] gdbserver crash in gdb/gdbserver/thread.c::thread_search_callback
2015-12-21 15:15 [RFA] gdbserver crash in gdb/gdbserver/thread.c::thread_search_callback Joel Brobecker
@ 2015-12-21 16:53 ` Pedro Alves
2015-12-22 15:27 ` pushed: " Joel Brobecker
0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2015-12-21 16:53 UTC (permalink / raw)
To: Joel Brobecker, gdb-patches
On 12/21/2015 03:15 PM, Joel Brobecker wrote:
> Connecting GDB to a LynxOS-178 GDBserver causes GDBserver to crash:
>
> % gdbserver :4444 simple_main
> Process simple_main created; pid = 19
> Listening on port 4444
> Remote debugging from host 205.232.38.10
> Segmentation fault (core dumped)
>
> We saw this crash on LynxOS and also when using GDBserver on Windows.
>
> The crash happens in thread_search_callback where the function
> calls the_target->thread_stopped (via the thread_stopped macro)
> without verifying whether the callback is NULL or not.
>
> For the record, the regression was introduced by:
>
> commit a67a9faef0e32886c83611cc7a0ba61e91123063
> Date: Mon Nov 30 16:05:26 2015 +0000
> Subject: gdbserver:prepare_access_memory: pick another thread
>
Whoops, sorry about that.
> gdb/gdbserver/ChangeLog:
>
> * target.c (thread_search_callback): Add check that
> the thread_stopped target callback is not NULL before
> calling it.
>
> Does the fix look good to you?
> Tested on both Windows (native gdbserver) and LynxOS using
> AdaCore's gdb-testsuite.
LGTM.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 3+ messages in thread
* pushed: Re: [RFA] gdbserver crash in gdb/gdbserver/thread.c::thread_search_callback
2015-12-21 16:53 ` Pedro Alves
@ 2015-12-22 15:27 ` Joel Brobecker
0 siblings, 0 replies; 3+ messages in thread
From: Joel Brobecker @ 2015-12-22 15:27 UTC (permalink / raw)
To: gdb-patches
> > gdb/gdbserver/ChangeLog:
> >
> > * target.c (thread_search_callback): Add check that
> > the thread_stopped target callback is not NULL before
> > calling it.
> >
> > Does the fix look good to you?
> > Tested on both Windows (native gdbserver) and LynxOS using
> > AdaCore's gdb-testsuite.
>
> LGTM.
Thanks, Pedro; pushed!
--
Joel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-12-22 15:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-21 15:15 [RFA] gdbserver crash in gdb/gdbserver/thread.c::thread_search_callback Joel Brobecker
2015-12-21 16:53 ` Pedro Alves
2015-12-22 15:27 ` pushed: " Joel Brobecker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox