[Python-Dev] stack check on Unix: any suggestions?

Charles G Waldman cgw@alum.mit.edu
Sat, 2 Sep 2000 19:52:33 -0500 (CDT)


I said:
 > This means that you're not hitting the rlimit at all but getting a 
 > real segfault!  Time to do setrlimit -c unlimited and break out GDB, 
 > I'd say.   
 
Thomas Wouters came back with: 
> I did figure out the problem isn't stackspace (which was already
> obvious) but *damned* if I know what the problem is.  I don't fancy
> doing it again just yet :P:P What I did see, however, was that the
> reason for the crash isn't the pure recursion. It looks like the
> recursiveness *does* get caught properly, and the interpreter raises
> an error. And then prints that error over and over again, probably
> once for every call to getattr(), and eventually *that* crashes (but
> why, I don't know. In one test I did, it crashed in int_print, the
> print function for int objects, which did 'fprintf(fp, "%ld",
> v->ival);'. The actual SEGV arrived inside fprintf's
> internals. v->ival was a valid integer (though a high one) and the
> problem was not derefrencing 'v'. 'fp' was stderr, according to its
> _fileno member.
 
I've got some more info: this crash only happens if you have built
with --enable-threads.  This brings in a different (thread-safe)
version of fprintf, which uses mutex locks on file objects so output
from different threads doesn't get scrambled together.  And the SEGV
that I saw was happening exactly where fprintf is trying to unlock the
mutex on stderr, so it can print "Maximum recursion depth exceeded".
 
This looks like more ammo for Guido's theory that there's something 
wrong with libpthread on linux, and right now I'm elbows-deep in the 
guts of libpthread trying to find out more.  Fun little project for a
Saturday night ;-)      
 
> 'ltrace' (if you have it) is also a nice tool to let loose on this
> kind of script, by the way, though it does make the test take a lot
> longer, and you really need enough diskspace to store the output ;-P
 
Sure, I've got ltrace, and also more diskspace than you really want to 
know about!

Working-at-a-place-with-lots-of-machines-can-be-fun-ly yr's,
					
					-Charles