public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/104495] New: call_once hangs in call after exceptional call
@ 2022-02-10 22:35 f.heckenbach@fh-soft.de
  2022-02-10 22:39 ` [Bug libstdc++/104495] " pinskia at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: f.heckenbach@fh-soft.de @ 2022-02-10 22:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104495

            Bug ID: 104495
           Summary: call_once hangs in call after exceptional call
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: f.heckenbach@fh-soft.de
  Target Milestone: ---

% cat test.cpp
#include <iostream>
#include <thread>
#include <mutex>

std::once_flag flag2;

void may_throw_function(bool do_throw)
{
  if (do_throw) {
    std::cout << "throw: call_once will retry\n";
    throw std::exception();
  }
  std::cout << "Didn't throw, call_once will not attempt again\n";
}

void do_once(bool do_throw)
{
  try {
    std::call_once(flag2, may_throw_function, do_throw);
  }
  catch (...) {
  }
}

int main()
{
    do_once (true);
    do_once (false);
}
% g++ test.cpp -pthread
% ./a.out
throw: call_once will retry
[hangs]

This is a simplified version of the example from
https://en.cppreference.com/w/cpp/thread/call_once -- the full example also
hangs.

My actual use case is a bit different, but it seems any call after an exception
call hangs; that's all that seems relevant.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-02-11 10:35 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-10 22:35 [Bug libstdc++/104495] New: call_once hangs in call after exceptional call f.heckenbach@fh-soft.de
2022-02-10 22:39 ` [Bug libstdc++/104495] " pinskia at gcc dot gnu.org
2022-02-10 22:41 ` f.heckenbach@fh-soft.de
2022-02-10 22:44 ` pinskia at gcc dot gnu.org
2022-02-10 22:49 ` f.heckenbach@fh-soft.de
2022-02-10 23:09 ` f.heckenbach@fh-soft.de
2022-02-10 23:20 ` redi at gcc dot gnu.org
2022-02-10 23:23 ` f.heckenbach@fh-soft.de
2022-02-10 23:28 ` redi at gcc dot gnu.org
2022-02-10 23:29 ` redi at gcc dot gnu.org
2022-02-10 23:34 ` f.heckenbach@fh-soft.de
2022-02-11 10:35 ` redi at gcc dot gnu.org

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).