<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - llvm 3.5 optimizer miscompile regression with zdoom"
   href="http://llvm.org/bugs/show_bug.cgi?id=21302">21302</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>llvm 3.5 optimizer miscompile regression with zdoom
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>ed0.88.prez@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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 <a href="https://github.com/rheit/zdoom.git">https://github.com/rheit/zdoom.git</a> 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));
#endif

which prevents the problems.

Then follow the instructions in <a href="http://zdoom.org/wiki/Compile_ZDoom_on_Linux">http://zdoom.org/wiki/Compile_ZDoom_on_Linux</a>
inside the new folder before the section:
<a href="http://zdoom.org/wiki/Compile_ZDoom_on_Linux#Compile">http://zdoom.org/wiki/Compile_ZDoom_on_Linux#Compile</a>

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:
<a href="https://github.com/freedoom/freedoom/releases/download/v0.9/freedoom-0.9.zip">https://github.com/freedoom/freedoom/releases/download/v0.9/freedoom-0.9.zip</a>

ZDoomEditDemo_v1_2.pk3, extracted from the archive file, downloadable at:
<a href="http://www.mediafire.com/download/w95mcmc83b5z18r/ZDoom_Editing_Demo_v1.2.zip">http://www.mediafire.com/download/w95mcmc83b5z18r/ZDoom_Editing_Demo_v1.2.zip</a>

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
fine.

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.

Sincerely,
Edward-san</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>