Bug 40790 - throw in custom C++ terminate handler creates infinite recursion
Summary: throw in custom C++ terminate handler creates infinite recursion
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc   
(Show other bugs)
Version: 7.1
Hardware: i686
OS: Linux
medium
high
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: David Lawrence
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-05-15 21:43 UTC by Louis-Dominique Dubeau
Modified: 2007-04-18 16:33 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2002-12-15 14:50:40 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

Description Louis-Dominique Dubeau 2001-05-15 21:43:53 UTC
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 17:26:23 UTC
FWIW, this problem is fixed in gcc 3.0


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