Bug 1372822

Summary: pthread_cancel inside exception handler and cancel point called from C++ code unexpected behavior
Product: Red Hat Enterprise Linux 8 Reporter: Paulo Andrade <pandrade>
Component: gccAssignee: Marek Polacek <mpolacek>
gcc sub component: gcc-toolset-10 QA Contact: Alexandra Petlanová Hájková <ahajkova>
Status: CLOSED UPSTREAM Docs Contact:
Severity: medium    
Priority: medium CC: ahajkova, cww, dbasant, fweimer, jakub, jwakely, mnewsome, mpolacek, ohudlick, pbhoot, sipoyare, vmukhame
Version: 8.2Keywords: Triaged
Target Milestone: rc   
Target Release: 8.2   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-04-06 18:41:17 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1461138, 1477664    
Attachments:
Description Flags
thread.cxx none

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.