<div dir="ltr">Can you fill in something for "<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"? Because I'm not sure I'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"><<a href="mailto:alex.pyattaev@gmail.com">alex.pyattaev@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I'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="some_file"<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>
> On Wed, Oct 5, 2011 at 6:51 PM, Amaury Forgeot d'Arc<br>
<<a href="mailto:amauryfa@gmail.com">amauryfa@gmail.com</a>>wrote:<br>
> > 2011/10/5 Ram Rachum <<a href="mailto:ram@rachum.com">ram@rachum.com</a>>:<br>
> > > Okay, I've spent a few hours print-debugging, and I think I've<br>
> > > almost got it.<br>
> > ><br>
> > > The crash happens on a line:<br>
> > > st = os.stat(s)<br>
> > ><br>
> > > inside `os.path.isdir`, where `s` is a string 'C:\\Documents and<br>
> > > Settings\\User\\My Documents\\Python<br>
> > > Projects\\GarlicSim\\garlicsim\\src' This is a directory that<br>
> > > happens not to exist, but of course this is not><br>
> > a<br>
> ><br>
> > > good reason to crash.<br>
> > > I have tried running `os.stat(s)` in the PyPy shell with that same<br>
> > > `s`,<br>
> ><br>
> > but<br>
> ><br>
> > > didn't get a crash there. I don't know why it's crashing in Nose but<br>
> > > not><br>
> > in<br>
> ><br>
> > > the shell.<br>
> > ><br>
> > > Does anyone have a clue?<br>
> ><br>
> > it's possible that it's a RPython-level exception, or a bad handle<br>
> > because too many files wait for the garbage collector to close them.<br>
> ><br>
> > Can you give more information about the crash itself?<br>
> > - What are the last lines printed in the console? Try to disable<br>
> > "stdout capture" in Nose, by passing the -s option.<br>
><br>
> This is the entire output:<br>
><br>
> Preparing to run tests using Python 2.7.1 (080f42d5c4b4, Aug 23 2011,<br>
> 11:41:11)<br>
> [PyPy 1.6.0 with MSC v.1500 32 bit]<br>
> Running tests directly from GarlicSim repo.<br>
> Pypy doesn't have wxPython, not loading `garlicsim_wx` tests.<br>
> nose.config: INFO: Set working dir to C:\Documents and Settings\User\My<br>
> Documents\Python Projects\GarlicSim<br>
> nose.config: INFO: Ignoring files matching ['^\\.', '^_', '^setup\\.py$']<br>
> nose.plugins.cover: INFO: Coverage report will include only packages:<br>
> ['garlicsim', 'garlicsim_lib', 'garlicsim_wx', 'test_garlicsim',<br>
> 'test_garlicsim_lib', 'test_garlicsim_wx', 'garlicsim', 'garlicsim_lib',<br>
> 'garlicsim_wx', 'test_garlicsim', 'test_garlicsim_lib', 'test_garlicsim_wx',<br>
> 'garlicsim', 'garlicsim_lib', 'garlicsim_wx', 'test_garlicsim',<br>
> 'test_garlicsim_lib', 'test_garlicsim_wx']<br>
><br>
><br>
><br>
><br>
> - after the pypy process has exited, type "echo %ERRORLEVEL%" in the<br>
><br>
> > same console, to print the exit code<br>
> > of the last process. Which number is it?<br>
><br>
> -1073741819<br>
><br>
> > --<br>
> > Amaury Forgeot d'Arc<br>
</div></div></blockquote></div><br></div>