public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
To: Martin Sebor <msebor@redhat.com>,
	 GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH] pthread_once hangs when init routine throws an exception [BZ #18435]
Date: Mon, 06 Jul 2015 13:18:00 -0000	[thread overview]
Message-ID: <559A8029.1000705@arm.com> (raw)
In-Reply-To: <557741C5.5060203@redhat.com>

On 09/06/15 20:43, Martin Sebor wrote:
> Attached is an updated version of the patch that addresses
> the LDFLAGS -> LDLIBS comment. Retested on ppc64.
> 
> Is it okay to commit?
> 
> Martin
> 
> On 05/31/2015 03:37 PM, Martin Sebor wrote:
>> > The C++ 2011 std::call_once function is specified to allow
>> > the initialization routine to exit by throwing an exception.
>> > Such an execution, termed exceptional, requires call_once to
>> > propagate the exception to its caller. A program may contain
>> > any number of exceptional executions but only one returning
>> > execution (which, if it exists, must be the last execution
>> > with the same once flag).
>> >
>> > On POSIX systems such as Linux std::call_once is implemented
>> > in terms of pthread_once. However, as discussed in libstdc++
>> > bug 66146 - "call_once not C++11-compliant on ppc64le," GLIBC's
>> > pthread_once hangs when the initialization function exits by
>> > throwing an exception on at least arm and ppc64 (though
>> > apparently not on x86_64). This effectively prevents call_once
>> > from conforming to the C++ requirements since there doesn't
>> > appear to be a thread-safe way to work around this problem in
>> > libstdc++.
>> >
>> > The attached patch changes pthread_once to handle gracefully
>> > init functions that exit by throwing exceptions. It has been
>> > tested on ppc64, ppc64le, and x86_64 with no regressions.
...
> diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
> index 84a7105..72d3e23 100644
> --- a/nptl/pthreadP.h
> +++ b/nptl/pthreadP.h
> @@ -536,16 +536,9 @@ extern void __librt_disable_asynccancel (int oldtype)
>  extern void __pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
>  				    void (*routine) (void *), void *arg)
>       attribute_hidden;
> -# undef pthread_cleanup_push
> -# define pthread_cleanup_push(routine,arg) \
> -  { struct _pthread_cleanup_buffer _buffer;				      \
> -    __pthread_cleanup_push (&_buffer, (routine), (arg));
>  
>  extern void __pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer,
>  				   int execute) attribute_hidden;
> -# undef pthread_cleanup_pop
> -# define pthread_cleanup_pop(execute) \
> -    __pthread_cleanup_pop (&_buffer, (execute)); }
>  #endif
>  
>  extern void __pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,

this broke

nptl/tst-join5
nptl/tst-once3

tests on aarch64.

the cleanup handler of the pthread_once and pthread_join
implementation don't run when they are canceled.

  parent reply	other threads:[~2015-07-06 13:18 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <556B7F10.40209@redhat.com>
2015-06-01  8:39 ` Florian Weimer
2015-06-01 16:27   ` Martin Sebor
2015-06-02  9:53     ` Mike Frysinger
2015-06-04 21:12       ` Martin Sebor
2015-06-03 11:36     ` Torvald Riegel
2015-06-01 10:20 ` Szabolcs Nagy
2015-06-01 19:47   ` Martin Sebor
2015-06-03 11:07     ` Torvald Riegel
2015-06-03 11:11       ` Jonathan Wakely
2015-06-03 20:14       ` Rich Felker
2015-06-03 20:24         ` Martin Sebor
2015-06-03 23:49           ` Rich Felker
2015-06-04  1:47             ` Martin Sebor
2015-06-04  5:38               ` Rich Felker
2015-06-04  7:29                 ` Martin Sebor
2015-06-08 11:41                 ` Jonathan Wakely
2015-06-08 14:38                   ` Szabolcs Nagy
2015-06-04  8:20           ` Torvald Riegel
2015-06-08 11:48             ` Jonathan Wakely
2015-06-08 16:01               ` Florian Weimer
2015-06-03 11:07   ` Torvald Riegel
2015-06-01 14:39 ` Andreas Schwab
2015-06-09 19:49 ` Martin Sebor
2015-06-15 22:14   ` Martin Sebor
2015-06-23  7:48     ` [PING 2] " Martin Sebor
     [not found]       ` <5593256B.5060402@redhat.com>
2015-07-01  0:06         ` [PING 3] " Rich Felker
2015-07-01 20:18           ` Martin Sebor
2015-07-01 21:27             ` Joseph Myers
2015-07-06 13:18   ` Szabolcs Nagy [this message]
2015-07-06 14:16     ` Martin Sebor
2015-07-06 14:58       ` Adhemerval Zanella
2015-07-06 16:33         ` Szabolcs Nagy
2015-07-06 17:09           ` Szabolcs Nagy
2015-07-08 11:00             ` Szabolcs Nagy
2015-07-08 16:09               ` Carlos O'Donell
2015-07-08 16:33                 ` Torvald Riegel
2015-07-08 16:52                   ` Szabolcs Nagy
2015-07-08 17:14                     ` Carlos O'Donell
2021-03-02 16:43                 ` Jakub Jelinek
2015-07-08 16:16 ` Carlos O'Donell
2015-07-08 21:28   ` Martin Sebor
2015-07-08 22:13     ` Szabolcs Nagy
2015-07-08 22:52       ` Martin Sebor
2015-07-08 23:42         ` Szabolcs Nagy
2015-07-09  4:46         ` Martin Sebor
2015-07-09 23:41           ` Martin Sebor
2021-03-03 12:52 Jakub Jelinek
2021-03-04 11:50 ` Florian Weimer
2021-03-04 13:00   ` Jakub Jelinek
2021-03-04 13:26     ` Florian Weimer
2021-03-04 14:14       ` Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=559A8029.1000705@arm.com \
    --to=szabolcs.nagy@arm.com \
    --cc=libc-alpha@sourceware.org \
    --cc=msebor@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).