This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 08/08] nptl: arm: Fix Race conditions in pthread cancellation (BZ#12683)
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: Alexander Monakov <amonakov at ispras dot ru>
- Cc: Phil Blundell <pb at pbcl dot net>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Thu, 3 Sep 2015 15:04:52 -0300
- Subject: Re: [PATCH 08/08] nptl: arm: Fix Race conditions in pthread cancellation (BZ#12683)
- Authentication-results: sourceware.org; auth=none
- References: <55E4C300 dot 9080800 at linaro dot org> <1441148926 dot 1680 dot 51 dot camel at pbcl dot net> <55E768E8 dot 8020904 at linaro dot org> <1441276001 dot 22688 dot 18 dot camel at pbcl dot net> <55E86CC9 dot 9040507 at linaro dot org> <1441297157 dot 22688 dot 26 dot camel at pbcl dot net> <55E883A4 dot 1030705 at linaro dot org> <alpine dot LNX dot 2 dot 20 dot 1509032043140 dot 607 at monopod dot intra dot ispras dot ru>
On 03-09-2015 14:48, Alexander Monakov wrote:
> On Thu, 3 Sep 2015, Adhemerval Zanella wrote:
>> On 03-09-2015 13:19, Phil Blundell wrote:
>>> On Thu, 2015-09-03 at 12:52 -0300, Adhemerval Zanella wrote:
>>>> I can change to:
>>>>
>>>> mov lr, pc
>>>> b __syscall_do_cancel
>>>>
>>>> Which explicit state it is a tail cail that do not return.
>>>
>>> If you set lr like that then the implication is that it will return
>>> (since otherwise lr would be unnecessary). A regular tail call would
>>> just do the branch without changing lr at all.
>>
>> My first approach was to use compiler output to check how it handle tail
>> call for ARM. For instance, the code:
>>
>> --
>>
>> void __do_cancel () __attribute__ ((noreturn));
>>
>> long int foo (long int nr);
>>
>> long int __syscall (long int *d, long int nr)
>> {
>> if (*d & 0x1)
>> __do_cancel ();
>>
>> return foo (nr);
>> }
>>
>> --
>>
>> generates the 'bl' for __do_cancel with both GCC 4.9 and GCC 6.0.
>
> To provide a bit of (potentially non-obvious) context: GCC deliberately
> suppresses tail call optimization when the call target is a noreturn function,
> with the intent of providing full backtraces if the noreturn function
> terminates the program.
>
> In the example above, call to 'foo' would be tail-call-optimized, while the
> call to '__do_cancel' wouldn't.
And my understanding is it requires because it is based on unwind information.
I have not dig on why exactly using 'b' shows some failures in tst-cancex{4,5,17,18},
but my wild guess is some backtracing information missing.
>
> Alexander
>