<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - libunwind (SEH on MinGW) : segfault during unwinding"
   href="https://bugs.llvm.org/show_bug.cgi?id=39935">39935</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>libunwind (SEH on MinGW) : segfault during unwinding
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>jeanmichael.celerier@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=21209" name="attach_21209" title="code that reproduces the problem">attachment 21209</a> <a href="attachment.cgi?id=21209&action=edit" title="code that reproduces the problem">[details]</a></span>
code that reproduces the problem

Hello,
I originally posted this issue here :
<a href="https://github.com/mstorsjo/llvm-mingw/issues/25">https://github.com/mstorsjo/llvm-mingw/issues/25</a>  

The attached repro gives an example which causes a segfault (with the
llvm-mingw toolchain)
The build.sh script will build a code and launch the program in the case which
causes the problem (segfault while unwinding). There are a bunch of files but
the actual stack trace is very short and only spans two files (main.cpp and
parser/sourcereader.cpp):

Thread 1 hit Catchpoint 1 (exception thrown), 0x0000000140010a90 in __cxa_throw
()
(gdb) bt
#0  0x0000000140010a90 in __cxa_throw ()
#1  0x000000014000657d in SourceReader::parseLocal (this=<optimized out>,
    fname=<optimized out>) at C:/dev/repro-except/parser\sourcereader.cpp:93
#2  0x0000000140006235 in SourceReader::parseFile (this=<optimized out>,
    fname=<optimized out>) at C:/dev/repro-except/parser\sourcereader.cpp:84
#3  0x000000014000c4fa in compileFaustFactory (argc=<optimized out>,
    argv=0x524250, name=<optimized out>, dsp_content=<optimized out>,
    error_msg=..., generate=<optimized out>)
    at C:/dev/repro-except\main.cpp:21
#4  0x000000014000c668 in main (argc=<optimized out>,
    argv=0x140012260 <typeinfo for faustexception>)
    at C:/dev/repro-except\main.cpp:33


The smallest change to the code path, for instance changing parseLocal from : 


Tree SourceReader::parseLocal(const char* fname)
{
    stringstream error;

    throw faustexception("blah");
    return gGlobal->gResult;
}

to

Tree SourceReader::parseLocal(const char* fname)
{
    throw faustexception("blah");
    return gGlobal->gResult;
}


or removing the untaken if branch in sourcereader.cpp:79, makes the problem go
away.

Also, it works at -O1, it's only starting from -O2 that it fails.

The same code works fine with clang on both linux and macos.</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>