Bug 495296 - Optimization Causes Modify LDT Code Returns a Different Value
Summary: Optimization Causes Modify LDT Code Returns a Different Value
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 10
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-04-11 10:58 UTC by Qian Cai
Modified: 2009-04-12 05:32 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2009-04-11 16:43:41 UTC
Type: ---
Embargoed:


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

Description Qian Cai 2009-04-11 10:58:56 UTC
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 Qian Cai 2009-04-11 11:00:22 UTC
Created attachment 339169 [details]
Test Program

Comment 2 Ulrich Drepper 2009-04-11 16:43:41 UTC
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 Qian Cai 2009-04-12 05:32:54 UTC
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.