<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>Le 13 juil. 2012 à 22:32, John McCall <<a href="mailto:rjmccall@apple.com">rjmccall@apple.com</a>> a écrit :</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Jul 13, 2012, at 12:17 PM, Jean-Daniel Dupas wrote:</div><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>While running the following code, it crashes due to an invalid free operation:</div><div><br></div><div><div>exc(8657) malloc: *** error for object 0x7f97c14039e0: pointer being freed was not allocated</div><div>*** set a breakpoint in malloc_error_break to debug</div><div>fish: Job 1, './exc' terminated by signal SIGABRT (Abort)</div></div><div><br></div><div>--- --- --- --- --- </div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(120, 73, 42); ">#include <span style="color: #d12f1b"><string></span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px; "><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "><span style="color: #bb2ca2">class</span> Error {</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(187, 44, 162); ">public<span style="">:</span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> <span style="color: #bb2ca2">explicit</span> <span style="color: #bb2ca2">inline</span> Error(<span style="color: #bb2ca2">const</span> std::string &str) noexcept {}</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">};</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px; "><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">std::string _cxx_strfmt() noexcept { <span style="color: #bb2ca2">return</span> std::string(); }</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px; "><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "><span style="color: #bb2ca2">int</span> main(<span style="color: #bb2ca2">int</span> argc, <span style="color: #bb2ca2">char</span> **argv) {</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> <span style="color: #bb2ca2">try</span> {</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> <span style="color: #bb2ca2">throw</span> Error(_cxx_strfmt());</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> } <span style="color: #bb2ca2">catch</span> (...) {}</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">}</div></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">------</div><div><br></div><div>compiled using </div><div>clang++ -std=c++11 exc.cpp</div><div><br></div><div>I can't see what is wrong with this code, but if I remove the <span style="font-family: Menlo; font-size: 11px; ">noexcept </span><span style="background-color: transparent;">declaration (either one), it stop crashing and run as expected.</span></div><div><span style="background-color: transparent;"><br></span></div><div>Is this something I'm doing wrong, or this is a subtle clang bug ? </div><div><br></div><div>I attach the llvm ir generate with noexcept (exc-crash.s) and the one without (exc.s)</div><div><br></div><div>If this is a bug in clang, tell me, I will fill a report.</div></div></blockquote><br></div><div>It's a clang bug; somehow we're unconditionally freeing the exception</div><div>in this case.</div><div><br></div><div>John.</div></div></blockquote><br></div><div>Thanks, I filled it as <a href="http://llvm.org/bugs/show_bug.cgi?id=13359" title="NEW - invalid codegen result in unexpected free of exception and crash" style="color: rgb(102, 51, 102); font-family: Verdana, sans-serif; font-size: small; font-weight: bold; background-color: rgb(255, 255, 255); ">Bug 13359</a> </div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px; "><div>-- Jean-Daniel</div><div><br></div><div><br></div></span><br class="Apple-interchange-newline">
</div>
<br></body></html>