zsh-workers
 help / color / mirror / code / Atom feed
* 3.0.8 math bug?
@ 2000-08-17 17:54 Dan Nelson
  2000-08-17 20:53 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Nelson @ 2000-08-17 17:54 UTC (permalink / raw)
  To: zsh-workers


Why does evaluating a non-numeric variable cause 3.0.8 to consume all
available RAM and then exit to the parent shell?  At least 3.1.9
doesn't completely exit, but I would expect invalid variables to
evaluate to 0 just like unset variables do.

(dan@dan)/tmp> zsh -f
dan% echo $ZSH_VERSION
3.0.8
dan% a=a
dan% (( a ))
zsh: fatal error: out of memory
(dan@dan)/tmp>

(dan@dan)/tmp> zsh31 -f
dan% echo $ZSH_VERSION
3.1.9
dan% a=a
dan% (( a ))
zsh: math recursion limit exceeded
dan%



-- 
	Dan Nelson
	dnelson@emsphone.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: 3.0.8 math bug?
  2000-08-17 17:54 3.0.8 math bug? Dan Nelson
@ 2000-08-17 20:53 ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2000-08-17 20:53 UTC (permalink / raw)
  To: Dan Nelson; +Cc: zsh-workers

On Thu, 17 Aug 2000, Dan Nelson wrote:

> Why does evaluating a non-numeric variable cause 3.0.8 to consume all
> available RAM and then exit to the parent shell?

The operational answer is "because all previous versions of zsh do that,
and it hasn't been fixed yet in 3.0.8."

The semantic answer is "because the value of a variable evaluated in math
context is treated as an expression, and that expression is itself
evaluated."

E.g.

b=7
a=b
(( a )) --> b --> 7

a="3 + 4"
(( a )) --> 3 + 4 --> 7

a=a
(( a )) --> a --> a --> a --> ...

Hence in 3.1.somethingmorethan6butIforgetwhat, an arbitrary limit on the
depth of math recursion was imposed, and you get:

> zsh: math recursion limit exceeded

This does mean that there are expressions you can evaluate in 3.0.8 that
will eventually resolve to a value, which you can't evaluate in 3.1.9.  
They're a lot more complicated than anything you'd be likely to write out
by hand, though.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: 3.0.8 math bug?
  2000-08-18  7:00 Sven Wischnowsky
@ 2000-08-18  8:56 ` Peter Stephenson
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2000-08-18  8:56 UTC (permalink / raw)
  To: Zsh hackers list

Sven wrote:
> > Hence in 3.1.somethingmorethan6butIforgetwhat, an arbitrary limit on the
> > depth of math recursion was imposed, and you get:
> > 
> > > zsh: math recursion limit exceeded
> 
> Btw, I wasn't happy about this behaviour at that time, but then I
> tried it with ksh and bash and both of them do the same as 3.1.x,
> i.e. they report an recursion-too-deep error. I haven't tried which
> shell allows the deepest recursion, though.

When we have a new system for storing parameters (hur, hur) we could do the
following:  mark a parameter as in use as aliases do, then if they come up
for retrieval while they're still marked, we just return zero.

-- 
Peter Stephenson <pws@csr.com>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: 3.0.8 math bug?
@ 2000-08-18  7:00 Sven Wischnowsky
  2000-08-18  8:56 ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Sven Wischnowsky @ 2000-08-18  7:00 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> ...
> 
> The semantic answer is "because the value of a variable evaluated in math
> context is treated as an expression, and that expression is itself
> evaluated."
> 
> ...
> 
> Hence in 3.1.somethingmorethan6butIforgetwhat, an arbitrary limit on the
> depth of math recursion was imposed, and you get:
> 
> > zsh: math recursion limit exceeded

Btw, I wasn't happy about this behaviour at that time, but then I
tried it with ksh and bash and both of them do the same as 3.1.x,
i.e. they report an recursion-too-deep error. I haven't tried which
shell allows the deepest recursion, though.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2000-08-18  8:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-08-17 17:54 3.0.8 math bug? Dan Nelson
2000-08-17 20:53 ` Bart Schaefer
2000-08-18  7:00 Sven Wischnowsky
2000-08-18  8:56 ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).