Bugzilla will be upgraded to version 5.0 on a still to be determined date in the near future. The original upgrade date has been delayed.

Bug 40790

Summary: throw in custom C++ terminate handler creates infinite recursion
Product: [Retired] Red Hat Linux Reporter: Louis-Dominique Dubeau <ldd>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED CURRENTRELEASE QA Contact: David Lawrence <dkl>
Severity: high Docs Contact:
Priority: medium    
Version: 7.1   
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-12-15 09:50:40 EST Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Louis-Dominique Dubeau 2001-05-15 17:43:53 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux 2.4.2-2-ldd i686; en-US; 0.7)
Gecko/20010316

Description of problem:
Calling throw inside of a custom C++ terminate handler (set using
set_terminate) generates a call to terminate right away.  try-catch blocks
seem to be ignored.

How reproducible:
Always

Steps to Reproduce:
1. Create minimal.cc containing:

#include <string>
#include <exception>

void my_terminate()
{
    cout << "in terminate" << endl;
    cout.flush();
    try
    {
        throw;
    }
    catch (...)
    {
	cout << "caught" << endl;
	cout.flush();
    }
    exit(-1);
}

int
main(int argc, char *argv[])
{
    set_terminate(my_terminate);

    throw exception();
}

2. make minimal

3. ./minimal
	

Actual Results:
in terminate
in terminate
in terminate
in terminate
[This is repeated until the program crashes.  A stack trace shows that
my_terminate is being called recursively.]

Expected Results:
in terminate
caught
[program stops here]

Additional info:

Important note: on RedHat 6.1, compiling and running the above program
generates the expected results!
Comment 1 Jay Berkenbilt 2001-06-20 13:26:23 EDT
FWIW, this problem is fixed in gcc 3.0