<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hello! I'm new to the field and I was trying a simple stackless embedding test and experienced problems.Here is the short source code to my test:<br><br><pre class="source"><pre class="de1"><span class="co2">#include <stackless_api.h></span><br><span class="co2">#include <windows.h></span><br> <br><span class="kw4">int</span> main<span class="br0">(</span><span class="kw4">void</span><span class="br0">)</span><br> <br><span class="br0">{</span><br>PyInterpreterState<span class="sy0">*</span> pys<span class="sy0">;</span><br>Py_Initialize<span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span><br>PyRun_SimpleString<span class="br0">(</span><span class="st0">"import stackless"</span><span class="br0">)</span><span class="sy0">;</span><br>PyRun_SimpleString<span class="br0">(</span><span class="st0">"print
 stackless.runcount"</span><span class="br0">)</span><span class="sy0">;</span><br>PyRun_SimpleString<span class="br0">(</span><span class="st0">"print stackless.getcurrent()"</span><span class="br0">)</span><span class="sy0">;</span><br>PyObject <span class="sy0">*</span>task<span class="sy0">;</span><br>task<span class="sy0">=</span>PyStackless_GetCurrent<span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span>    <span class="co1">//  <==== CRASH HERE</span><br>Py_DECREF<span class="br0">(</span>task<span class="br0">)</span><span class="sy0">;</span><br> <br><span class="kw1">return</span> <span class="nu0">1</span><span class="sy0">;</span><br><span class="br0">}<br><br>I am using MSVC 8 and an unmodified distribution of Python 2.7.1 Stackless 3.1b3 060516,<br>built with the same compiler.<br>The crash happens inside </span>PyStackless_GetCurrent, which looks like this:<br><br>PyObject
 *<br>PyStackless_GetCurrent(void)<br>{<br>    PyThreadState *ts = PyThreadState_GET();<br>    PyObject *t = (PyObject*)ts->st.current;<br><br>    Py_INCREF(t);<br>    return t;<br>}<br><br>The crash happens on Py_INCREF(t), because the thread state object returned by PyThreadState_GET<br>doesn't seem to be properly initialized.<br>I'm probably missing something very basic, but any help is appreciated.<br><br>Cheers!<br></pre></pre><br></td></tr></table><br>