Re: [PATCH]13217 thread apply all detach throws a SEGFAULT

Pedro Alves
2013-01-14T15:46:03Z

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