[llvm-bugs] [Bug 35902] New: False positive alignment error with -fsanitize=undefined with virtual base

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jan 11 01:54:19 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=35902

            Bug ID: 35902
           Summary: False positive alignment error with
                    -fsanitize=undefined with virtual base
           Product: clang
           Version: 5.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: securesneakers at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 19654
  --> https://bugs.llvm.org/attachment.cgi?id=19654&action=edit
Minimal example that reproduces the issue

Attached program generates false misalignment errors when compiled with
-fsanitize=undefined

$ clang++ --version
clang version 5.0.0 (tags/RELEASE_500/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

$ uname -s -m
Linux x86_64

$ clang++ -std=c++11 -O2 -fsanitize=undefined minimal.cpp && ./a.out
minimal.cpp:9:8: runtime error: constructor call on misaligned address
0x7ffdd1e1e658 for type 'struct Base2', which requires 16 byte alignment

The program crashes afterwards, I have reported a separate bug:
https://bugs.llvm.org/show_bug.cgi?id=35901. This bug is about false positive
error.

Attached example contains following hierarchy:

struct alignas(16) Base1 { };
struct Base2 : virtual Base1 { };
struct Base3 : virtual Base2 { };

alignof(Base2) is set to 16 due to alignment of its base class. But when Base3
is instantiated, Base2 is placed with alignment of 8 as it should be according
to Itanium C++ ABI (due to its non-virtual alignment being equal 8):
https://refspecs.linuxfoundation.org/cxxabi-1.75.html#class-types. Yet
sanitizer complains about alignment not being 16.

Seems that sanitizer checks address using "normal" alignment when "non-virtual
alignment" should be used.

I have reported the same issue for GCC:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83780

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180111/bedb18e9/attachment.html>


More information about the llvm-bugs mailing list