Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
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.
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.
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
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.
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.
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.
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.