<div dir="ltr">Can you fill in something for &quot;<span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); ">#Do something that uses lots of RAM&quot;? Because I&#39;m not sure I&#39;ll get it right.</span><br>

<br><div class="gmail_quote">On Thu, Oct 6, 2011 at 12:02 AM, Alex Pyattaev <span dir="ltr">&lt;<a href="mailto:alex.pyattaev@gmail.com">alex.pyattaev@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

I&#39;ve had a very similar stuff, as in something crashing only when run many<br>
times when I had a bug in a container type implemented in C. Basically, I had<br>
wrong refcount for the objets, which caused them to be freed by garbage<br>
collectore while they have been still used. Maybe something similar happens in<br>
the code that wraps windows API that handles file opening. That would explain<br>
why the bug never happens on linux. A good candidate would be incorrect<br>
refcount for the return value if the file does not  exist. Try something like<br>
this:<br>
s=&quot;some_file&quot;<br>
rets=[]<br>
for i in range(1000):<br>
        rets.append(os.stat(s))<br>
        gc.collect()<br>
        #Do something that uses lots of RAM (but a random amount, preferably in<br>
small blocks)<br>
        print rets<br>
if it crashes then you have exactly that issue. 1000 might be not enough to<br>
toggle the crash though, as you need the OS to actually allocate different<br>
segments of memory for this to work. The more RAM you have the more cycles you<br>
need to toggle the crash. At least this approach helped me to debug extension<br>
modules written in C.<br>
<br>
BTW, for me on VM the test case does not crash. But I have SP2 windows there.<br>
<div><div></div><div class="h5">On Wednesday 05 October 2011 19:37:07 Ram Rachum wrote:<br>
&gt; On Wed, Oct 5, 2011 at 6:51 PM, Amaury Forgeot d&#39;Arc<br>
&lt;<a href="mailto:amauryfa@gmail.com">amauryfa@gmail.com</a>&gt;wrote:<br>
&gt; &gt; 2011/10/5 Ram Rachum &lt;<a href="mailto:ram@rachum.com">ram@rachum.com</a>&gt;:<br>
&gt; &gt; &gt; Okay, I&#39;ve spent a few hours print-debugging, and I think I&#39;ve<br>
&gt; &gt; &gt; almost got it.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; The crash happens on a line:<br>
&gt; &gt; &gt;     st = os.stat(s)<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; inside `os.path.isdir`, where `s` is a string &#39;C:\\Documents and<br>
&gt; &gt; &gt; Settings\\User\\My Documents\\Python<br>
&gt; &gt; &gt; Projects\\GarlicSim\\garlicsim\\src&#39; This is a directory that<br>
&gt; &gt; &gt; happens not to exist, but of course this is not&gt;<br>
&gt; &gt; a<br>
&gt; &gt;<br>
&gt; &gt; &gt; good reason to crash.<br>
&gt; &gt; &gt; I have tried running `os.stat(s)` in the PyPy shell with that same<br>
&gt; &gt; &gt; `s`,<br>
&gt; &gt;<br>
&gt; &gt; but<br>
&gt; &gt;<br>
&gt; &gt; &gt; didn&#39;t get a crash there. I don&#39;t know why it&#39;s crashing in Nose but<br>
&gt; &gt; &gt; not&gt;<br>
&gt; &gt; in<br>
&gt; &gt;<br>
&gt; &gt; &gt; the shell.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Does anyone have a clue?<br>
&gt; &gt;<br>
&gt; &gt; it&#39;s possible that it&#39;s a RPython-level exception, or a bad handle<br>
&gt; &gt; because too many files wait for the garbage collector to close them.<br>
&gt; &gt;<br>
&gt; &gt; Can you give more information about the crash itself?<br>
&gt; &gt; - What are the last lines printed in the console? Try to disable<br>
&gt; &gt; &quot;stdout capture&quot; in Nose, by passing the -s option.<br>
&gt;<br>
&gt; This is the entire output:<br>
&gt;<br>
&gt; Preparing to run tests using Python 2.7.1 (080f42d5c4b4, Aug 23 2011,<br>
&gt; 11:41:11)<br>
&gt; [PyPy 1.6.0 with MSC v.1500 32 bit]<br>
&gt; Running tests directly from GarlicSim repo.<br>
&gt; Pypy doesn&#39;t have wxPython, not loading `garlicsim_wx` tests.<br>
&gt; nose.config: INFO: Set working dir to C:\Documents and Settings\User\My<br>
&gt; Documents\Python Projects\GarlicSim<br>
&gt; nose.config: INFO: Ignoring files matching [&#39;^\\.&#39;, &#39;^_&#39;, &#39;^setup\\.py$&#39;]<br>
&gt; nose.plugins.cover: INFO: Coverage report will include only packages:<br>
&gt; [&#39;garlicsim&#39;, &#39;garlicsim_lib&#39;, &#39;garlicsim_wx&#39;, &#39;test_garlicsim&#39;,<br>
&gt; &#39;test_garlicsim_lib&#39;, &#39;test_garlicsim_wx&#39;, &#39;garlicsim&#39;, &#39;garlicsim_lib&#39;,<br>
&gt; &#39;garlicsim_wx&#39;, &#39;test_garlicsim&#39;, &#39;test_garlicsim_lib&#39;, &#39;test_garlicsim_wx&#39;,<br>
&gt; &#39;garlicsim&#39;, &#39;garlicsim_lib&#39;, &#39;garlicsim_wx&#39;, &#39;test_garlicsim&#39;,<br>
&gt; &#39;test_garlicsim_lib&#39;, &#39;test_garlicsim_wx&#39;]<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; - after the pypy process has exited, type &quot;echo %ERRORLEVEL%&quot; in the<br>
&gt;<br>
&gt; &gt; same console, to print the exit code<br>
&gt; &gt; of the last process. Which number is it?<br>
&gt;<br>
&gt; -1073741819<br>
&gt;<br>
&gt; &gt; --<br>
&gt; &gt; Amaury Forgeot d&#39;Arc<br>
</div></div></blockquote></div><br></div>