RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1222110 - std::terminate incorrectly called on x86 when throwing an exception in a stacktrace that includes a C function
Summary: std::terminate incorrectly called on x86 when throwing an exception in a stac...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: gcc
Version: 6.6
Hardware: i686
OS: Unspecified
unspecified
high
Target Milestone: rc
: ---
Assignee: Jakub Jelinek
QA Contact: qe-baseos-tools-bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-05-15 19:03 UTC by Dave Johansen
Modified: 2015-05-18 15:35 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-05-18 11:51:03 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
C file to test exception handling (48 bytes, text/plain)
2015-05-15 19:03 UTC, Dave Johansen
no flags Details
C++ file to test exception handling (340 bytes, text/x-csrc)
2015-05-15 19:04 UTC, Dave Johansen
no flags Details

Description Dave Johansen 2015-05-15 19:03:35 UTC
Created attachment 1026015 [details]
C file to test exception handling

Description of problem:
std::terminate() is being called and killing the program instead of the expected behavior of unwinding the stack and calling destructors.

Version-Release number of selected component (if applicable):
4.4.7-11

How reproducible:
Always

Steps to Reproduce:
1. gcc -g -nostdlib -c test_exception.c -o test_exception_c.o
2. g++ -g -nostdlib -c test_exception.cpp -o test_exception_cpp.o
3. g++ -g test_exception_c.o test_exception_cpp.o -o test_exception
4. ./test_exception

Actual results:
Program aborts/core dumps.

Expected results:
Exception handled in normal manner by unwinding the stack.

Additional info:
This only happens on x86 (x64 handles the exception as expected).
When built on x86 Fedora 21 with gcc 4.9.2-6 the exception is also handled as expected but when the executable built on RHEL 6 is run on Fedora 21, it aborts just like on RHEL 6.

Comment 1 Dave Johansen 2015-05-15 19:04:09 UTC
Created attachment 1026016 [details]
C++ file to test exception handling

Comment 3 Dave Johansen 2015-05-16 03:40:19 UTC
I apologize, the -nostdlib is not necessary. It was part of a test I was doing before submitting the bugzilla and it accidentally crept in here. The "Steps to Reproduce" should be (but I believe it doesn't really make any difference):
1. gcc -g -c test_exception.c -o test_exception_c.o
2. g++ -g -c test_exception.cpp -o test_exception_cpp.o
3. g++ -g test_exception_c.o test_exception_cpp.o -o test_exception
4. ./test_exception

Comment 4 Dave Johansen 2015-05-16 04:54:25 UTC
In case it's helpful, g++ 4.5.1-4 from Fedora 14 is the most recent version that I was able to reproduce the problem with. g++ 4.6.3-2 from Fedora 16 demonstrated the correct/expected behavior of unwinding the stack and not calling terminate.

Comment 5 Jakub Jelinek 2015-05-18 11:51:03 UTC
When compiling C++, the compiler defaults to -fexceptions, while for C the default is -fno-exceptions.  To be able to throw through C frames, you need them to be compiled with -fexceptions, or -funwind-tables, or -fasynchronous-unwind-tables.  Later compilers default to -fasynchronous-unwind-tables on more architectures than older ones, and -fasynchronous-unwind-tables has been the default on x86_64 far earlier than on i686.
For simply throwing through, you don't really need asynchronous unwind tables though, just -fexceptions or -funwind-tables should be good enough.

Comment 6 Dave Johansen 2015-05-18 15:35:13 UTC
Thanks for the clarification and sorry for the noise based on my lack of knowledge. Just for the sake of documentation, adding -fexceptions when building test_exception.c fixes the issue on RHEL 6/gcc 4.4.7-11 and RHEL 5.11/gcc 4.1.2-55 but didn't work on RHEL 5.3/gcc 4.1.2-44. So I'm guessing that some fix between release 44 and 55 fixed this issue on RHEL 5.


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