[lldb-dev] [PATCH] Unexpected group-stop with threading under Linux
Andrew MacPherson
andrew.macp at gmail.com
Mon Jan 27 09:09:27 PST 2014
Hey Todd, great! I think if we end up in there and it's not a SIGSTOP then
we have no idea what's going on and it's not clear what the correct
behaviour would be. I'm happy to wrap the whole thing in an if statement
checking for SIGSTOP though if you think that's best, though it's not clear
whether the thing to do is to continue or return at that point.
Thanks!
On Mon, Jan 27, 2014 at 6:06 PM, Todd Fiala <tfiala at google.com> wrote:
> Verified this fixes it. I'll go ahead and check it in.
>
>
> On Mon, Jan 27, 2014 at 9:00 AM, Todd Fiala <tfiala at google.com> wrote:
>
>> I'm giving this a shot now locally. The change looks reasonable to me -
>> any ptrace experts disagree?
>>
>> The one bit I'm not entirely sure about is: if assertions are disabled,
>> and for some reason the WSTOPSIG(status) is not SIGSTOP (since we're not
>> explicitly checking before the Resume(wait_pid, SIGSTOP) call), how badly
>> can that gunk things up? An if check before the Resume call would at least
>> stop the wrong signal from getting sent to the inferior if I'm reading it
>> right.
>>
>>
>> On Mon, Jan 27, 2014 at 2:47 AM, Andrew MacPherson <andrew.macp at gmail.com
>> > wrote:
>>
>>> This patch addresses a bug where in a multi-threaded program a new
>>> signal from the inferior may be received before all group-stop messages
>>> from an earlier signal have been handled. The attached .cpp file exposes
>>> the issue:
>>>
>>> - clang++ -o thread thread.cpp -lpthread -g -O0
>>> - lldb ./thread
>>> - r
>>> - hit Ctrl-C
>>> - br set -f thread.cpp -l 11
>>> - c
>>> - <hang>
>>>
>>> A breakpoint is usually hit before all the group-stop messages involved
>>> in restarting the process are handled and the internal state then gets out
>>> of sync.
>>>
>>> The attached patch solves the issue and all unit tests pass, I'm not a
>>> ptrace expert though so there may be a more appropriate fix. The group-stop
>>> handling was taken from the existing ProcessMonitor::MonitorCallback.
>>>
>>> Thanks,
>>>
>>> Andrew
>>>
>>>
>>>
>>> _______________________________________________
>>> lldb-dev mailing list
>>> lldb-dev at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
>>>
>>>
>>
>>
>> --
>> Todd Fiala | Software Engineer | tfiala at google.com | 650-943-3180
>>
>
>
>
> --
> Todd Fiala | Software Engineer | tfiala at google.com | 650-943-3180
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20140127/a00ef1bb/attachment.html>
More information about the lldb-dev
mailing list