This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 08/08] nptl: arm: Fix Race conditions in pthread cancellation (BZ#12683)



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
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]