Bug 495296 - Optimization Causes Modify LDT Code Returns a Different Value
Optimization Causes Modify LDT Code Returns a Different Value
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
10
All Linux
low Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-04-11 06:58 EDT by CAI Qian
Modified: 2009-04-12 01:32 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-04-11 12:43:41 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Test Program (1.41 KB, text/plain)
2009-04-11 07:00 EDT, CAI Qian
no flags Details

  None (edit)
Description CAI Qian 2009-04-11 06:58:56 EDT
Description of problem:
The attached code returns different values with and without compilation optimization.

$ gcc -Wall modify_ldt.c -o modify_ldt
$ ./modify_ldt 
a = 42
a = 99
PASS

$ gcc -Wall -O1 modify_ldt.c -o modify_ldt
$ ./modify_ldt 
a = 42
a = 42
FAIL

Version-Release number of selected component (if applicable):
glibc-2.9-3.i686
gcc-4.3.2-7.i386
kernel-2.6.27.5-117.fc10.i686

How reproducible:
always

The code is based on Ulrich Drepper's test -- Make sure LDT is propagated correctly.
Comment 1 CAI Qian 2009-04-11 07:00:22 EDT
Created attachment 339169 [details]
Test Program
Comment 2 Ulrich Drepper 2009-04-11 12:43:41 EDT
The test code isn't correct.  The compiler cannot look inside the asm statements in main() and see that they are really necessary.  Based on the information given the compiler can drop some of them.

Change all asms in main from

  asm(...)

to

  asm volatile(...)

and the code works fine.
Comment 3 CAI Qian 2009-04-12 01:32:54 EDT
Thanks Ulrich! I have fixed the test program, and it works fine indeed.

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