<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">The scenario you describe might happen if the main tasklet is entered more than once, but with different structured exception handling in place. yes.  Interesting,
 we didn’t think of this.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">How involved is this exception chain repatching of which you speak?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I think that if you simply post a .patch file here, made from the sources at
<a href="http://hg.python.com/stackless">http://hg.python.com/stackless</a>, but Richard Tew will know for sure
</span><span style="font-size:11.0pt;font-family:Wingdings;color:#1F497D">J</span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">K<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></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 lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> stackless-bounces@stackless.com [mailto:stackless-bounces@stackless.com]
<b>On Behalf Of </b>Gil Colgate<br>
<b>Sent:</b> 3. apríl 2012 16:28<br>
<b>To:</b> stackless@stackless.com<br>
<b>Subject:</b> [Stackless] Exception handling crashes, how to contribute<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I had the unfortunate experience of mixing python and C++ code on the Windows environment on a large program with multiple libraries not written by me.<br>
<br>
The C++ code uses the structured exception handling protocol, and stackless does no properly handle this. This could result in crashes in the following way:<br>
<br>
Whenever a python tasklet is suspended the top of the exception chain is saved by stackless. This very well could be pointing into code
<b>above the python stack into the main program</b>. When the python tasklet is called again, it's stack is put back<b> *in the same place*,</b> but the environment above the stack<b> *might be different*.</b> This would cause the exception chain to screw up
 in the part where the exception chain points above the stack. <br>
<br>
This would cause a crash on an exception... for example a function uses OutputDebugStr (which routes by using an exception).... the exception handler itself could crash.<br>
<br>
I have corrected this issue in my local copy of Stackless.. it involves changes to stacklesseval.c and involves patching the exception chain properly when tasklet switching, in cases when windows structured execption handling is defined.  I have not contributed
 to stackless open source before, but I think anyone else getting peculiar crashes with exceptions on Windows might appreciate this fix.<br>
<br>
I would like someone to explain the procedure to contribute to me.<br>
    <o:p></o:p></p>
</div>
</div>
</body>
</html>