No subject
[132.151.7.31])by cnri.reston.va.us (8.9.1a/8.9.1) with ESMTP id
KAA10024;Fri, 5 Nov 1999 10:02:51 -0500 (EST)
Received: from eric.cnri.reston.va.us (eric.cnri.reston.va.us
[10.27.10.23])by kaluha.cnri.reston.va.us (8.9.1b+Sun/8.9.1) with ESMTP id
KAA03654;Fri, 5 Nov 1999 10:02:57 -0500 (EST)
Received: from CNRI.Reston.VA.US (localhost [127.0.0.1])by
eric.cnri.reston.va.us (8.9.3+Sun/8.9.1) with ESMTP id KAA16554;Fri, 5 Nov
1999 10:02:54 -0500 (EST)
Message-Id: <199911051502.KAA16554@eric.cnri.reston.va.us>
In-reply-to: Your message of "Fri, 05 Nov 1999 09:16:35 EST."
<199911051416.JAA24937@python.org>
References: <199911051416.JAA24937@python.org>
> Don't know if this is considered a bug:
> Python.exe crashed when I tried to use a recursive function,
> like the infamous factorial.
> I've downloaded and tried this on both Python 1.5.1 and 1.5.2
> of the Windows 95/98/NT version.
>
> The function is as follows
>
> def fact(n):
> if n==1: return 1
> else: return n*fact(n)
>
> fact(1) returned 1 with no problems.
> But fact(2) or any argument greater than 1 crashed python
> with a Windows application error window popping up.
>
> I've run this before on a Linux version of Python without any problems.
Do you realize that your code has a bug? It recurses infinitely
because you are calling fact(n) instead of fact(n-1). On Linux, you
would have gotten a stack overflow error.
Unfortunately, the stack overflow code on Windows is broken (the limit
on recursion is too high, so it runs out of stack memory causing a
crash before the recursion limit is triggered).
Christian Tismer has posted a patch for the binary (python15.dll)
which solves this. It has also of course been fixed in our source
code.
--Guido van Rossum (home page: http://www.python.org/~guido/)
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com