Bug 1515209

Summary: gdb prints wrong result of double variable in -mavx mode
Product: [Fedora] Fedora Reporter: Peter Steinbach <steinbach>
Component: gdbAssignee: Jan Kratochvil <jan.kratochvil>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 26CC: jan.kratochvil, pmuldoon, sergiodj
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: gdb-8.0.1-33.fc27 gdb-8.0.1-33.fc26 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-12-12 11:25:47 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
code to reproduce this bug with C++ none

Description Peter Steinbach 2017-11-20 12:04:48 UTC
Created attachment 1355685 [details]
code to reproduce this bug with C++

Description of problem:
gdb reports the wrong contents of a variable, while printing the content of the variable to stdout provides good results

Version-Release number of selected component (if applicable):
8.0.1-30.fc26

How reproducible:
Compile this code
```
$ cat test.cpp
#include <iostream>

int main(int argc, char** argv){

    double rvalue = 0.3;
    std::cout << "- " << rvalue << "\n";
    double a,b;

    rvalue = 0.3;

    std::cout << ": " << rvalue << "\n";
    return rvalue < 1. ? 0 : 1;

}
```
with gcc/g++ and run it inside gdb. the contents of rvalue are printed to the screen in a bogus fashion. Only after the second assignment of "rvalue", gdb prints the correct result. Motivates wrong conclusions in practice.

Steps to Reproduce:
1. g++ -mavx -g test.cpp
2. gdb ./a.out
3. (gdb) b test.cpp:5
4. (gdb) rrun
5. (gdb) next
6. (gdb) p rvalue
$1 = 7.0607433379231282e-184


Actual results:
$1 = 7.0607433379231282e-184

Expected results:
$1 = 0.29999999

Additional info:
- the example above is a contrived example that reproduces the behavior found with a real development project
- Also found this behavior on fc25 with 7.12.1-48.fc25 before upgrading
- Also observed this on Ubuntu 16.04.3 with 7.11.1-0ubuntu1~16.5
- running the code, prints the right results to stdout
- the behavior can be reproduced with C

Comment 1 Jan Kratochvil 2017-11-26 19:06:36 UTC
Tracked upstream: https://sourceware.org/bugzilla/show_bug.cgi?id=22499

Comment 2 Fedora Update System 2017-12-06 19:35:23 UTC
gdb-8.0.1-32.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-ffd35436cf

Comment 3 Fedora Update System 2017-12-06 19:35:32 UTC
gdb-8.0.1-32.fc27 has been submitted as an update to Fedora 27. https://bodhi.fedoraproject.org/updates/FEDORA-2017-0bf0f4ba91

Comment 4 Fedora Update System 2017-12-06 20:41:43 UTC
gdb-8.0.1-33.fc27 has been submitted as an update to Fedora 27. https://bodhi.fedoraproject.org/updates/FEDORA-2017-7328f5705a

Comment 5 Fedora Update System 2017-12-06 20:41:49 UTC
gdb-8.0.1-33.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-5139b2c38c

Comment 6 Fedora Update System 2017-12-09 07:27:38 UTC
gdb-8.0.1-33.fc26 has been pushed to the Fedora 26 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-5139b2c38c

Comment 7 Fedora Update System 2017-12-10 00:31:52 UTC
gdb-8.0.1-33.fc27 has been pushed to the Fedora 27 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-7328f5705a

Comment 8 Fedora Update System 2017-12-12 11:25:47 UTC
gdb-8.0.1-33.fc27 has been pushed to the Fedora 27 stable repository. If problems still persist, please make note of it in this bug report.

Comment 9 Fedora Update System 2017-12-12 13:43:39 UTC
gdb-8.0.1-33.fc26 has been pushed to the Fedora 26 stable repository. If problems still persist, please make note of it in this bug report.