This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH]13217 thread apply all detach throws a SEGFAULT
- From: Pedro Alves <palves at redhat dot com>
- To: "Bilal, Muhammad" <Muhammad_Bilal at mentor dot com>
- Cc: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Mon, 14 Jan 2013 15:45:54 +0000
- Subject: Re: [PATCH]13217 thread apply all detach throws a SEGFAULT
- References: <97B73E257CC18646B0B5D3DD77DCBDD158E8FD@EU-MBX-02.mgc.mentorg.com> <97B73E257CC18646B0B5D3DD77DCBDD158EBC9@EU-MBX-02.mgc.mentorg.com>
Hi Bilal,
The problem with this fix is that it handles one
specific crash, but is not a complete fix, as it
still leaves undefined behavior in place, which may
well manifest in similar crashes, or worse, random corruption.
The issue is that the command applies to each thread may
not remove _all_ threads (as detected by your patch), but cause
the currently iterated thread to exit, and thus, (at least)
this "tp->next" reference:
for (tp = thread_list; tp; tp = tp->next)
^^^^^^^^^^^^^
if (thread_alive (tp))
Please coordinate with Ali Anwar @ Mentor. He was
working on this issue a couple months back, and posted a
more complete patch, though review showed some more
work was necessary.
--
Pedro Alves