<div dir="ltr"><div dir="ltr" class="gmail_msg"><div class="gmail_msg">Depending on your tolerance of imposing other constraints and debugging hacks, it can be possible to enable just enough exception handling. For the JuliaLang JIT, we force off FPO on all functions, then in the NotifyObjectEmitted callback, we can hand-code the expected stack frame prologue layout (<a href="https://github.com/JuliaLang/julia/blob/35422b2233788c31af93d4b41e6239f6bb20cc3a/src/debuginfo.cpp#L474-L488">https://github.com/JuliaLang/julia/blob/35422b2233788c31af93d4b41e6239f6bb20cc3a/src/debuginfo.cpp#L474-L488</a>) and add it to the RTLFunctionTable (<a href="https://github.com/JuliaLang/julia/blob/35422b2233788c31af93d4b41e6239f6bb20cc3a/src/debuginfo.cpp#L156-L160">https://github.com/JuliaLang/julia/blob/35422b2233788c31af93d4b41e6239f6bb20cc3a/src/debuginfo.cpp#L156-L160</a>). It's not particularly elegant, </div></div><div dir="ltr" class="gmail_msg"><div class="gmail_msg">but it does make the stack walker happy enough to permit us to handle async exceptions and do statistical profiling.</div><div dir="ltr" class="gmail_msg"><br></div>The exception handling instructions work if you are emitting static code. But the relocations are not implemented in the JIT, nor is the memory manager able to ensure that the object layout will be valid, so there is no OOTB solution right now in LLVM.</div><div dir="ltr" class="gmail_msg"><br class="gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On Sun, Mar 5, 2017 at 9:18 PM <a href="mailto:haifeng.qin@wellintech.com" class="gmail_msg" target="_blank">haifeng.qin@wellintech.com</a> via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_msg">
<div class="gmail_msg"><span class="gmail_msg"></span><span style="color:rgb(0,0,0);background-color:rgba(0,0,0,0)" class="gmail_msg">Thank you for your reply. </span></div><div class="gmail_msg"><span style="color:rgb(0,0,0);background-color:rgba(0,0,0,0)" class="gmail_msg"><br class="gmail_msg"></span></div><div class="gmail_msg"><span style="background-color:rgba(0,0,0,0);font-size:10.5pt;line-height:1.5" class="gmail_msg">Can the function be implemented by exception handling instructions</span><span style="font-size:10.5pt;line-height:1.5;background-color:window" class="gmail_msg">(<a href="http://llvm.org/docs/ExceptionHandling.html#id34" class="gmail_msg" target="_blank">http://llvm.org/docs/ExceptionHandling.html#id34</a>)</span><span style="background-color:rgba(0,0,0,0);font-size:10.5pt;line-height:1.5" class="gmail_msg">?</span></div>
<div class="gmail_msg"><br class="gmail_msg"></div><hr style="width:210px;height:1px" color="#b5c4df" size="1" align="left" class="gmail_msg">
<div class="gmail_msg"><span class="gmail_msg"><div style="MARGIN:10px;FONT-FAMILY:verdana;FONT-SIZE:10pt" class="gmail_msg"><div class="gmail_msg"><a href="mailto:haifeng.qin@wellintech.com" class="gmail_msg" target="_blank">haifeng.qin@wellintech.com</a></div></div></span></div>
<blockquote style="margin-top:0px;margin-bottom:0px;margin-left:0.5em" class="gmail_msg"><div class="gmail_msg"> </div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm" class="gmail_msg"><div style="PADDING-RIGHT:8px;PADDING-LEFT:8px;FONT-SIZE:12px;FONT-FAMILY:tahoma;COLOR:#000000;BACKGROUND:#efefef;PADDING-BOTTOM:8px;PADDING-TOP:8px" class="gmail_msg"><div class="gmail_msg"><b class="gmail_msg">From:</b> <a href="mailto:rnk@google.com" class="gmail_msg" target="_blank">Reid Kleckner</a></div><div class="gmail_msg"><b class="gmail_msg">Date:</b> 2017-03-02 02:20</div><div class="gmail_msg"><b class="gmail_msg">To:</b> <a href="mailto:haifeng.qin@wellintech.com" class="gmail_msg" target="_blank">haifeng.qin@wellintech.com</a></div><div class="gmail_msg"><b class="gmail_msg">CC:</b> <a href="mailto:llvm-dev@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev</a></div><div class="gmail_msg"><b class="gmail_msg">Subject:</b> Re: [llvm-dev] How to catch EXCEPTION_ACCESS_VIOLATION exceptions on win64</div></div></div></blockquote></div><div class="gmail_msg"><blockquote style="margin-top:0px;margin-bottom:0px;margin-left:0.5em" class="gmail_msg"><div class="gmail_msg"><div class="m_-9005819193966606824m_-8166895028780692593FoxDiv20170306101351922890 gmail_msg"><div dir="ltr" class="gmail_msg">I would not expect you to be able to catch any exceptions originating from code JITed by LLVM on Win64. Nobody has implemented the code to register the unwind data necessary to do this. The linked bug describes the steps necessary to implement this functionality.</div><div class="gmail_extra gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg">On Mon, Feb 27, 2017 at 12:34 AM, <a href="mailto:haifeng.qin@wellintech.com" class="gmail_msg" target="_blank">haifeng.qin@wellintech.com</a> via llvm-dev <span dir="ltr" class="gmail_msg"><<a href="mailto:llvm-dev@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br class="gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="gmail_msg">
<div class="gmail_msg"><span style="color:rgb(0,0,238)" class="gmail_msg">LLVM3.8 version.<br class="gmail_msg"><br class="gmail_msg"><a href="https://bugs.llvm.org//show_bug.cgi?id=24233" class="gmail_msg" target="_blank">https://bugs.llvm.org//show_bug.cgi?id=24233</a>. The example can catch exception. But I use my own code for testing, CustomEHMemoryManager allocated memory address is very large, allocateCodeSection, allocateDataSection assigned address (more than 32 bit address space) is getting smaller and smaller. Cause registerEHFrames to fail.<br class="gmail_msg">3.9.1 or 4.0.0 version has been supported on win x64? Or how to solve this problem?</span><span class="gmail_msg"></span></div><div class="gmail_msg"><span style="color:rgb(0,0,0);font-size:10.5pt;line-height:1.5;background-color:rgba(0,0,0,0)" class="gmail_msg"><br class="gmail_msg"></span></div><span style="color:rgb(0,0,0);background-color:rgba(0,0,0,0)" class="gmail_msg"></span>
<div class="gmail_msg"><br class="gmail_msg"></div><hr style="width:210px;height:1px" color="#b5c4df" size="1" align="left" class="gmail_msg">
<div class="gmail_msg"><span class="gmail_msg"><div style="MARGIN:10px;FONT-FAMILY:verdana;FONT-SIZE:10pt" class="gmail_msg"><div class="gmail_msg"><a href="mailto:haifeng.qin@wellintech.com" class="gmail_msg" target="_blank">haifeng.qin@wellintech.com</a></div></div></span></div>
<blockquote style="margin-top:0px;margin-bottom:0px;margin-left:0.5em" class="gmail_msg"><div class="gmail_msg"> </div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm" class="gmail_msg"><div style="PADDING-RIGHT:8px;PADDING-LEFT:8px;FONT-SIZE:12px;FONT-FAMILY:tahoma;COLOR:#000000;BACKGROUND:#efefef;PADDING-BOTTOM:8px;PADDING-TOP:8px" class="gmail_msg"><div class="gmail_msg"><b class="gmail_msg">发件人:</b> <a href="mailto:haifeng.qin@wellintech.com" class="gmail_msg" target="_blank">haifeng.qin@wellintech.com</a></div><div class="gmail_msg"><b class="gmail_msg">发送时间:</b> 2017-02-17 10:38</div><div class="gmail_msg"><b class="gmail_msg">收件人:</b> <a href="mailto:llvm-dev@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev</a></div><div class="gmail_msg"><b class="gmail_msg">主题:</b> 回复: How to catch EXCEPTION_ACCESS_VIOLATION exceptions on win64</div></div></div><div class="gmail_msg"><div class="m_-9005819193966606824m_-8166895028780692593h5 gmail_msg"><div class="gmail_msg"><div class="m_-9005819193966606824m_-8166895028780692593m_-983558963573570572FoxDiv20170227162200485570 gmail_msg">
<div class="gmail_msg"><span class="gmail_msg"></span><span style="color:rgb(0,0,0);background-color:rgba(0,0,0,0)" class="gmail_msg">I'm sorry。<br class="gmail_msg">I make mistakes. SE can be catched.</span></div>
<div class="gmail_msg"><br class="gmail_msg"></div><hr style="width:210px;height:1px" color="#b5c4df" size="1" align="left" class="gmail_msg">
<div class="gmail_msg"><span class="gmail_msg"><div style="MARGIN:10px;FONT-FAMILY:verdana;FONT-SIZE:10pt" class="gmail_msg"><div class="gmail_msg"><a href="mailto:haifeng.qin@wellintech.com" class="gmail_msg" target="_blank">haifeng.qin@wellintech.com</a></div></div></span></div>
<blockquote style="margin-top:0px;margin-bottom:0px;margin-left:0.5em" class="gmail_msg"><div class="gmail_msg"> </div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm" class="gmail_msg"><div style="PADDING-RIGHT:8px;PADDING-LEFT:8px;FONT-SIZE:12px;FONT-FAMILY:tahoma;COLOR:#000000;BACKGROUND:#efefef;PADDING-BOTTOM:8px;PADDING-TOP:8px" class="gmail_msg"><div class="gmail_msg"><b class="gmail_msg">发件人:</b> <a href="mailto:haifeng.qin@wellintech.com" class="gmail_msg" target="_blank">haifeng.qin@wellintech.com</a></div><div class="gmail_msg"><b class="gmail_msg">发送时间:</b> 2017-02-16 17:48</div><div class="gmail_msg"><b class="gmail_msg">收件人:</b> <a href="mailto:llvm-dev@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev</a></div><div class="gmail_msg"><b class="gmail_msg">主题:</b> How to catch EXCEPTION_ACCESS_VIOLATION exceptions on win64</div></div></div><div class="gmail_msg"><div class="m_-9005819193966606824m_-8166895028780692593m_-983558963573570572FoxDiv20170217103622312439 gmail_msg">
<div class="gmail_msg"><span class="gmail_msg"></span><div class="gmail_msg"><span style="color:rgb(0,0,0);background-color:rgba(0,0,0,0)" class="gmail_msg">For help:</span></div><div class="gmail_msg"><span style="color:rgb(0,0,0);background-color:rgba(0,0,0,0)" class="gmail_msg">Llvm generated instruction calls a function (extern), the function will have a SEH exception (EXCEPTION_ACCESS_VIOLATION), But JIT can not capture the exception of the EXCEPTION_ACCESS_VIOLATION. I saw Bug 24233. EXCEPTION_ACCESS_VIOLATION exception cannot be captured after modification. </span></div><div class="gmail_msg"><span style="color:rgb(0,0,0);background-color:rgba(0,0,0,0)" class="gmail_msg"><br class="gmail_msg"></span></div><div class="gmail_msg"><span style="color:rgb(0,0,0);background-color:rgba(0,0,0,0)" class="gmail_msg">How to catch EXCEPTION_ACCESS_VIOLATION exceptions on win64 ?</span></div></div>
<div class="gmail_msg"><br class="gmail_msg"></div><hr style="width:210px;height:1px" color="#b5c4df" size="1" align="left" class="gmail_msg">
<div class="gmail_msg"><span class="gmail_msg"><div style="MARGIN:10px;FONT-FAMILY:verdana;FONT-SIZE:10pt" class="gmail_msg"><div class="gmail_msg"><a href="mailto:haifeng.qin@wellintech.com" class="gmail_msg" target="_blank">haifeng.qin@wellintech.com</a></div></div></span></div>
</div></div></blockquote>
</div></div></div></div></blockquote>
</div><br class="gmail_msg">_______________________________________________<br class="gmail_msg">
LLVM Developers mailing list<br class="gmail_msg">
<a href="mailto:llvm-dev@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev@lists.llvm.org</a><br class="gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class="gmail_msg">
<br class="gmail_msg"></blockquote></div><br class="gmail_msg"></div>
</div></div></blockquote></div>_______________________________________________<br class="gmail_msg">
LLVM Developers mailing list<br class="gmail_msg">
<a href="mailto:llvm-dev@lists.llvm.org" class="gmail_msg" target="_blank">llvm-dev@lists.llvm.org</a><br class="gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class="gmail_msg">
</blockquote></div></div></div>