Stack overflow

dj trombley badzen at yifan.net
Sat Dec 18 00:21:55 EST 1999


homunq at my-deja.com wrote:
> 
> I recently had a subtle __getattr__ bug that led to infinite recursion
> and thus stack overflow. This causes PythonWin to crash, rather than
> just raising an exception. Ugly.
> 
> I heard something about a patch that would fix this. Does anyone know
> where I would find this?
> 
> If there isn't a patch, or if the patch isn't a planned component of the
> next python version, I'd like to vote (as a PSA member) that this is
> important. Yes, of course I know in retrospect that if I were a Real
> Programmer this would have been the first thing I thought of when I got
> my crashing behavior. But it's still ugly behaviour, and especially in
> light of CP4E it shouldn't be how things work.
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.


The patch is really merely a convienence so you don't have to
recompile.  
It is available at
http://www.deja.com/[LBURL=_LBHT,LBT,ST_rn=ap]/threadmsg_ct.xp?AN=484809938
as Thomas Heller pointed out in a seperate thread.

The binary it was created against was presumably produced by changing
the value of MAX_RECURSION_DEPTH in the python source
(python/ceval.c:336) to a smaller value than the default 10,000 so that
a windows machine will not run out of stack space before fenceposting. 
Also, there is an implementation of Python which does not use the C
stack available at http://www.pns.cc/stackless/stackless.htm.  I've not
tried this personally, but it should theoretically behave better under
such conditions.

-dj

Dave Trombley
<badzen at yifan.net>



More information about the Python-list mailing list