[Bug 1383334] Re: simple C++ program exhibits data corruption when compiled with -fstrict-aliasing
Miklos Reiter
miklos.reiter at navetas.com
Tue Nov 25 14:51:08 UTC 2014
I have re-submitted this bug report to the Linaro bug tracker:
https://bugs.linaro.org/show_bug.cgi?id=933
** Bug watch added: Linaro Bug Tracking System #933
https://bugs.linaro.org/show_bug.cgi?id=933
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-4.8-armhf-cross in Ubuntu.
https://bugs.launchpad.net/bugs/1383334
Title:
simple C++ program exhibits data corruption when compiled with
-fstrict-aliasing
Status in “gcc-4.8-armhf-cross” package in Ubuntu:
New
Bug description:
When cross-compiled using the command line:
$ arm-linux-gnueabihf-g++-4.8 -fPIC -o armGccBugTest armGccBugTest.cpp -std=c++11 -Wall -O2
the attached program generates the incorrect output:
# clobbered_pair: 0x00000000, 0x00000000
# clobbered_pair: 0x88888888, 0x44444444
The correct output is:
# clobbered_pair: 0x00000000, 0x00000000
# clobbered_pair: 0x00000000, 0x00000000
This is produced as expected when compiling with:
$ arm-linux-gnueabihf-g++-4.8 -fPIC -o armGccBugTest armGccBugTest.cpp -std=c++11 -Wall -O2 -fno-strict-aliasing
(Also, compiling to the native x86-64 architecture using g++-4.8 produces correct output using either optimization settings.)
The data from the ticks_t instance created on line 33 ends up
overwriting the temporary pair_t() passed in the fourth argument to
print_clobbered_pair(). Inspecting the disassembled code of the main
function, it seems that the compiler attempts to re-use the temporary
default-constructed pair_t() created on line 31 for the second call to
print_clobbered_pair() on line 34. However, the memory location on the
stack has been overwritten with the ticks_t instance created on line
33.
(We have reduced the problem to the attached minimal test case from a
much more complicated system. Details such as the seemingly
unnecessary user-defined copy constructor of the struct ticks_t or the
unused arguments of the function print_clobbered_pair() are essential
to reproducing the problem.)
ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: g++-4.8-arm-linux-gnueabihf 4.8.2-16ubuntu4cross0.11
ProcVersionSignature: Ubuntu 3.13.0-37.64-generic 3.13.11.7
Uname: Linux 3.13.0-37-generic x86_64
ApportVersion: 2.14.1-0ubuntu3.5
Architecture: amd64
CurrentDesktop: X-Cinnamon
Date: Mon Oct 20 15:15:20 2014
ProcEnviron:
TERM=xterm
PATH=(custom, no user)
XDG_RUNTIME_DIR=<set>
LANG=en_GB.UTF-8
SHELL=/bin/bash
SourcePackage: gcc-4.8-armhf-cross
UpgradeStatus: No upgrade log present (probably fresh install)
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.8-armhf-cross/+bug/1383334/+subscriptions
More information about the foundations-bugs
mailing list