[Bug 2023424] [NEW] GCC 13 on Lunar exhibits AddressSanitizer/UndefinedBehaviorSanitizer bug that doesn't manifest elsewhere
Edward Nolan
2023424 at bugs.launchpad.net
Fri Jun 9 21:57:49 UTC 2023
Public bug reported:
When initializing a class with a data member with alignment
`__attribute__((aligned(64)))` and enabling both AddressSanitizer and
UndefinedBehaviorSanitizer, Ubuntu 23.04's version of g++,
13-20230320-1ubuntu1, triggers UndefinedBehaviorSanitizer warnings on
valid code.
One-liner reproduction:
```
docker run ubuntu:23.04 bash -c 'apt-get update && apt-get install -y g++-13 && echo "struct Packet { int a = 0; int b __attribute__((aligned(64))); }; int main() { Packet packet; }" > ./foo.cpp && g++-13 -fsanitize=address -fsanitize=undefined ./foo.cpp && ./a.out'
```
```
foo.cpp:1:8: runtime error: member access within misaligned address 0x7f535a800020 for type 'struct Packet', which requires 64 byte alignment
0x7f535a800020: note: pointer points here
fe 7f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
^
```
This also occurs if a more recent version, 13.1.0-2ubuntu2~23.04, is
installed from the ubuntu-toolchain-r PPA:
```
docker run ubuntu:23.04 bash -c 'apt-get update && apt-get install -y software-properties-common && add-apt-repository ppa:ubuntu-toolchain-r/ppa && apt-get update && apt-get install -y g++-13 && echo "struct Packet { int a = 0; int b __attribute__((aligned(64))); }; int main() { Packet packet; }" > ./foo.cpp && g++-13 -fsanitize=address -fsanitize=undefined ./foo.cpp && ./a.out'
```
The issue does not manifest on Fedora:
```
docker run fedora:38 bash -c 'yum -y update && yum -y install g++ libasan libubsan && echo "struct Packet { int a = 0; int b __attribute__((aligned(64))); }; int main() { Packet packet; }" > ./foo.cpp && g++ -fsanitize=address -fsanitize=undefined ./foo.cpp && ./a.out'
```
Or on Compiler Explorer: https://godbolt.org/z/Ybr6cfEGj
I suspect that an Ubuntu GCC patch is introducing the bug.
** Affects: gcc-13 (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-13 in Ubuntu.
https://bugs.launchpad.net/bugs/2023424
Title:
GCC 13 on Lunar exhibits AddressSanitizer/UndefinedBehaviorSanitizer
bug that doesn't manifest elsewhere
Status in gcc-13 package in Ubuntu:
New
Bug description:
When initializing a class with a data member with alignment
`__attribute__((aligned(64)))` and enabling both AddressSanitizer and
UndefinedBehaviorSanitizer, Ubuntu 23.04's version of g++,
13-20230320-1ubuntu1, triggers UndefinedBehaviorSanitizer warnings on
valid code.
One-liner reproduction:
```
docker run ubuntu:23.04 bash -c 'apt-get update && apt-get install -y g++-13 && echo "struct Packet { int a = 0; int b __attribute__((aligned(64))); }; int main() { Packet packet; }" > ./foo.cpp && g++-13 -fsanitize=address -fsanitize=undefined ./foo.cpp && ./a.out'
```
```
foo.cpp:1:8: runtime error: member access within misaligned address 0x7f535a800020 for type 'struct Packet', which requires 64 byte alignment
0x7f535a800020: note: pointer points here
fe 7f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
^
```
This also occurs if a more recent version, 13.1.0-2ubuntu2~23.04, is
installed from the ubuntu-toolchain-r PPA:
```
docker run ubuntu:23.04 bash -c 'apt-get update && apt-get install -y software-properties-common && add-apt-repository ppa:ubuntu-toolchain-r/ppa && apt-get update && apt-get install -y g++-13 && echo "struct Packet { int a = 0; int b __attribute__((aligned(64))); }; int main() { Packet packet; }" > ./foo.cpp && g++-13 -fsanitize=address -fsanitize=undefined ./foo.cpp && ./a.out'
```
The issue does not manifest on Fedora:
```
docker run fedora:38 bash -c 'yum -y update && yum -y install g++ libasan libubsan && echo "struct Packet { int a = 0; int b __attribute__((aligned(64))); }; int main() { Packet packet; }" > ./foo.cpp && g++ -fsanitize=address -fsanitize=undefined ./foo.cpp && ./a.out'
```
Or on Compiler Explorer: https://godbolt.org/z/Ybr6cfEGj
I suspect that an Ubuntu GCC patch is introducing the bug.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-13/+bug/2023424/+subscriptions
More information about the foundations-bugs
mailing list