Bug 1372822 - pthread_cancel inside exception handler and cancel point called from C++ code unexpected behavior
Summary: pthread_cancel inside exception handler and cancel point called from C++ code...
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: gcc
Version: 8.2
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: 8.2
Assignee: Marek Polacek
QA Contact: Alexandra Petlanová Hájková
URL:
Whiteboard:
Depends On:
Blocks: 1461138 1477664
TreeView+ depends on / blocked
 
Reported: 2016-09-02 19:14 UTC by Paulo Andrade
Modified: 2023-07-18 14:19 UTC (History)
12 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-04-06 18:41:17 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
thread.cxx (479 bytes, text/plain)
2016-09-02 19:14 UTC, Paulo Andrade
no flags Details


Links
System ID Private Priority Status Summary Last Updated
GNU Compiler Collection 78015 0 P3 NEW pthread_cancel while some exception is pending results in std::terminate () 2020-12-18 10:11:18 UTC

Description Paulo Andrade 2016-09-02 19:14:52 UTC
Created attachment 1197277 [details]
thread.cxx

In the attached test case, if flush is called, it
will fail with the message:

terminate called after throwing an instance of 'std::runtime_error'

  The test case fails because of 'endl'.

  Other kinds of cancellation points work as expected.

Comment 2 Marek Polacek 2016-10-04 09:44:14 UTC
Wrong component.

Comment 4 Jakub Jelinek 2016-10-18 07:36:44 UTC
Simpler testcase, without STL, needs just libsupc++ and libpthread:

#include <pthread.h>
#include <unistd.h>

namespace __cxxabiv1
{  
  class __forced_unwind
  {
    virtual ~__forced_unwind() throw();
    virtual void __pure_dummy() = 0; 
  };
}

int a;

extern "C" void *
fun (void *)
{
  try
  {
    throw 1;
  }
  catch (int &)
  {
    try
    {
      char buf[10];
      for (;;)
	read (4, buf, 0);
    }
    catch (__cxxabiv1::__forced_unwind &)
    {
      a = 5;
      throw;
    }
  }

  return NULL;
}

int
main ()
{
  pthread_t thread;
  pthread_create (&thread, NULL, fun, NULL);
  pthread_cancel (thread);
  pthread_join (thread, NULL);
}

Comment 5 Jakub Jelinek 2016-10-18 07:37:51 UTC
All GCC versions affected.

Comment 10 Divya 2017-07-31 05:15:11 UTC
Hello 

Can we get a update on likelyhood of this getting fixed in RHEL-6?

Comment 32 Marek Polacek 2021-04-06 18:41:17 UTC
This BZ depends on the upstream bug being fixed.  There hasn't been any progress, so I'm closing this BZ in favor of the upstream bug.


Note You need to log in before you can comment on or make changes to this bug.