[LLVMbugs] [Bug 21302] New: llvm 3.5 optimizer miscompile regression with zdoom

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Oct 16 13:11:29 PDT 2014


            Bug ID: 21302
           Summary: llvm 3.5 optimizer miscompile regression with zdoom
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: ed0.88.prez at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Hello, I have a problem with a big open source program called ZDoom.

The problem is that with the release of clang 3.5, the llvm optimizer
miscompiles a portion of the code so that the program crashes with suitable
input. To reproduce it, follow the instructions:

Download the source with git:
git clone https://github.com/rheit/zdoom.git path/to/zdoom

Before compiling the program, open src/p_acs.cpp and remove this workaround:

// [EP] Clang 3.5.0 optimizer miscompiles this function and causes random
// crashes in the program. I hope that Clang 3.5.x will fix this.
#if defined(__clang__) && __clang_major__ == 3 && __clang_minor__ >= 5
    asm("" : "+g" (NumScripts));

which prevents the problems.

Then follow the instructions in http://zdoom.org/wiki/Compile_ZDoom_on_Linux
inside the new folder before the section:

After that, do this:

create a folder where to run cmake (release_clang_3.5, whatever you want), then
inside the folder, run:

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \
      -DCMAKE_C_COMPILER=path/to/clang-3.5 \
      -DCMAKE_CXX_COMPILER=path/to/clang++-3.5 \
      -DNO_ASM=1 \
      -DVALGRIND=1 \
      -DCMAKE_CXX_FLAGS=-std=c++11 ..

if anything goes fine, run:

make -j4

In order to reproduce the problem, you need to download two files:

freedoom.wad , extracted from the archive file, downloadable at:

ZDoomEditDemo_v1_2.pk3, extracted from the archive file, downloadable at:

Save the two files in $HOME/.zdoom .

You have everything, just run (with valgrind too):

./zdoom -iwad freedoom.wad -file ZDoomEditDemo_v1_2.pk3

You should be able get a crash which is not catched by the program and closes
suddenly, if you compiled the program with clang 3.5.

Sometimes the crash happens in other places, and sometimes the crash happens
when closing the program (esc to open the menu -> quit game -> confirm).

you run it with valgrind, you'll get an error which is not present with
clang 3.4 (should be the first one in the error list), then the program works

If you want to check with address sanitizer, you have to disable asan-globals
because for some reason asan does not like data sorting into custom sections.

I can't help you with the debugging other than seeing that the problem happens
in that portion of the code where there's the workaround.


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/20141016/f046edc9/attachment.html>

More information about the llvm-bugs mailing list