[llvm-bugs] [Bug 42567] New: Possible miscompilation by clang-cl versions 7, 8, and 9 targeting 32-bit Windows

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jul 10 10:44:04 PDT 2019


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

            Bug ID: 42567
           Summary: Possible miscompilation by clang-cl versions 7, 8, and
                    9 targeting 32-bit Windows
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bspencer at blackberry.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

Created attachment 22221
  --> https://bugs.llvm.org/attachment.cgi?id=22221&action=edit
Program demonstrating the bug

The attached program, when compiled with clang-cl versions 7, 8, and 9 (from
apt.llvm.org for Debian stretch) crashes when targeting 32-bit Windows.  It
does not crash when targeting 64-bit Windows with clang-cl or when using MSVC
(15.9.12 and other versions).

The attached archive contains a (POSIX) Makefile that can build on Linux using
a selection of compilers.  Building with MSVC (on Windows or on Linux) always
produces an executable that works.  Building with clang-cl for 32-bit always
produces an executable that fails.

For example:

$ make
clang version 9.0.0-svn364966-1~exp1+0~20190702204433.1332~1.gbpb44072 (trunk)
LLD 9.0.0
INCLUDE="/home/bspencer/msvc2017-15.9.12/ucrt/Include/10.0.17134.0/ucrt;/home/bspencer/msvc2017-15.9.12/vc/Tools/MSVC/14.16.27023/include;/home/bspencer/msvc2017-15.9.12/ucrt/Include/10.0.17134.0/shared;/home/bspencer/msvc2017-15.9.12/ucrt/Include/10.0.17134.0/um"
clang-cl-9 -Wno-unused-private-field -EHsc -analyze- -O2 -MD -W4 -WX -m32
-Wno-unused-private-field -c -Foprog.obj prog.cc
INCLUDE="/home/bspencer/msvc2017-15.9.12/ucrt/Include/10.0.17134.0/ucrt;/home/bspencer/msvc2017-15.9.12/vc/Tools/MSVC/14.16.27023/include;/home/bspencer/msvc2017-15.9.12/ucrt/Include/10.0.17134.0/shared;/home/bspencer/msvc2017-15.9.12/ucrt/Include/10.0.17134.0/um"
clang-cl-9 -Wno-unused-private-field -EHsc -analyze- -O2 -MD -W4 -WX -m32
-Wno-unused-private-field -c -Folib.obj lib.cc
LIB="/home/bspencer/msvc2017-15.9.12/ucrt/Lib/10.0.17134.0/ucrt/x86;/home/bspencer/msvc2017-15.9.12/vc/Tools/MSVC/14.16.27023/lib/x86;/home/bspencer/msvc2017-15.9.12/ucrt/Lib/10.0.17134.0/um/x86"
lld-link-9  /OUT:prog.exe prog.obj lib.obj

It fails both under Wine and real Windows:

$ wine ./prog.exe
Try!
Catch!
wine: Unhandled page fault on execute access to 0x2f409fde at address
0x2f409fde (thread 0023), starting debugger...

C:> prog.exe
Try!
Catch!
(Windows crash dialog box)

The crash happens in an std::thread function accessing an exception thrown and
caught within that thread.  Minimizing the test case further in any way that I
tried avoided the bug.

-- 
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/20190710/7ad4056b/attachment-0001.html>


More information about the llvm-bugs mailing list