You're welcome. We encountered this when a C function we called from python called a library function that did an "OutputDebugStr", which basically does an int-3 ... it prints the string by causing an exception that is picked up by the debugger. This library had C++ exception handling with some exceptions handled, but not the OutputDebugStr.<br>
<br>This could happen to anyone who is unfortunate to need to call precompiled libraries written in C++ that use exception handling. I was able to paper over the bug at first by compiling out the OutputDebugStr calls, but fixed the bug seriously later.<br>
<br><div class="gmail_quote">On Tue, Apr 17, 2012 at 4:26 AM, Kristján Valur Jónsson <span dir="ltr"><<a href="mailto:kristjan@ccpgames.com">kristjan@ccpgames.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">






<div link="blue" vlink="purple" lang="EN-GB">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I looked at this and I think it is probably ok.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">The reason we were doing this messing with SEH code was not to support SEH In the context of stackless, but to make sure that we were not accidentally trampling
 any higher SEH in place when doing task switching.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">As long as this patch does that, then we should be fine.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">We should probably make sure that the “stub” never has any SEH handlers to begin with, so that an exception in a fresh tasklet doesn’t cause those to start
 to try to unwind the stack because it makes no sense.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I’ll take another look and this and then get it committed when I find the time. 
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Thanks!<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">K<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="EN-US">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="EN-US"> <a href="mailto:stackless-bounces@stackless.com" target="_blank">stackless-bounces@stackless.com</a> [mailto:<a href="mailto:stackless-bounces@stackless.com" target="_blank">stackless-bounces@stackless.com</a>]
<b>On Behalf Of </b>Gil Colgate<br>
<b>Sent:</b> 16. apríl 2012 18:33<br>
<b>To:</b> The Stackless Python Mailing List<br>
<b>Subject:</b> Re: [Stackless] Patch to exception handler.<u></u><u></u></span></p>
</div>
</div><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">Did this meet with anyone's approval?<u></u><u></u></p>
<div>
<p class="MsoNormal">On Mon, Apr 9, 2012 at 11:43 AM, Gil Colgate <<a href="mailto:gcolgate@gmail.com" target="_blank">gcolgate@gmail.com</a>> wrote:<u></u><u></u></p>
<p class="MsoNormal">Here is a fix for the exception handler, I included just the .patch.<br>
<br>
    This corrects the problems with python having a different exception the environment when the item is called again.<br>
    <br>
    In the previous code, whenever a python tasklet was suspended the top of the exception chain was saved. This very well could be a pointer into code above the python stack into the main program. When the python tasklet is called again, it's stack is put
 back *in the same place*, but the environment above the stack *might be different*. This would cause the exception chain to screw up in the part where the exception chain points above the stack. This was the cause of the broken exception chain bug.<br>

    <br>
      <br>
    If a tasklet has none of it's own exception chains, we will discover this by reading the exception list and seeing that the address is above the stack, so we don't need to save or restore it it.<br>
    <br>
    If, on the other hand, the tasklet has a chain we save it. When restoring it we look at the current chain and insert the chain from the restored stack into it at the appropriate spot, so that the tasklet's chain points correctly into it's parent's change.<br>

    <br>
    Stack slicing: Stackless in general has a problem with stack slicing. This code will work in when the stack is sliced (I tested it with 2K stack slices and try-catches everywhere) but certain exceptions that belonged to inactive stack slices will not be
 executed since they are not currently linked into the chain.  <u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div></div></div>
</div>
</div>

<br>_______________________________________________<br>
Stackless mailing list<br>
<a href="mailto:Stackless@stackless.com">Stackless@stackless.com</a><br>
<a href="http://www.stackless.com/mailman/listinfo/stackless" target="_blank">http://www.stackless.com/mailman/listinfo/stackless</a><br></blockquote></div><br>