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 754729 - GCC optimization hiding NULL-dereference bug
Summary: GCC optimization hiding NULL-dereference bug
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: gcc
Version: 6.4
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Jakub Jelinek
QA Contact: qe-baseos-tools-bugs
URL:
Whiteboard:
Depends On:
Blocks: 754730
TreeView+ depends on / blocked
 
Reported: 2011-11-17 15:15 UTC by Stephen Gallagher
Modified: 2011-12-16 19:49 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 754730 (view as bug list)
Environment:
Last Closed: 2011-11-24 11:17:23 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Sample program demonstrating the issue (222 bytes, text/plain)
2011-11-17 15:18 UTC, Stephen Gallagher
no flags Details

Description Stephen Gallagher 2011-11-17 15:15:24 UTC
Description of problem:
GCC optimization at level -O1 or higher hides a NULL-dereference bug in an 'if' statement.

Version-Release number of selected component (if applicable):
gcc-4.4.5-6.el6.x86_64 and gcc-4.6.2-1.fc16.x86_64

How reproducible:
Every time.

Steps to Reproduce:
1. Compile the attached sample program with -O1, -O2 or -O3
  
Actual results:
Program runs to completion, returning success.

Expected results:
Program should crash due to a segmentation fault attempting to dereference 'ptr' in the IF statement.


Additional info:
If the attached program is built with -O0, the crash does not occur (and may hang around to cause unrelated issues later that are more difficult to track down).

Comment 1 Stephen Gallagher 2011-11-17 15:18:09 UTC
Created attachment 534210 [details]
Sample program demonstrating the issue

Comment 4 Jakub Jelinek 2011-11-24 11:17:23 UTC
That is fine, dereferencing a NULL pointer results in undefined behavior, when you reach such a statement the program can do anything, format your disk, segfault, anything else, and the compiler may optimize based on the assumption that it doesn't happen.


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