From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15145 invoked by alias); 24 Apr 2012 14:18:08 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 30453 Received: (qmail 25825 invoked from network); 24 Apr 2012 14:17:54 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Tue, 24 Apr 2012 14:37:06 +0100 From: Peter Stephenson To: "Zsh Hackers' List" Subject: Re: MAX_ARRLEN Message-ID: <20120424143706.3ccc490d@pwslap01u.europe.root.pri> In-Reply-To: <120423093812.ZM5059@torch.brasslantern.com> References: <20120423162711.42a6bad1@pwslap01u.europe.root.pri> <120423093812.ZM5059@torch.brasslantern.com> Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.101.10.18] X-Scanned-By: MailControl 7.7.0.1 (www.mailcontrol.com) on 10.68.0.128 On Mon, 23 Apr 2012 09:38:12 -0700 Bart Schaefer wrote: > On Apr 23, 4:27pm, Peter Stephenson wrote: > } What's the right thing to do? There are various grades ranging from > } making it compilable out, through making it compile-time configurable > } with an option to compile out, through making it an option to have the > } check turned on, to having a variable that we check using getiparam() > } each time, to having a special variable so that we don't need to get it > } each time. I think the last option with a clearly named variable such > } as ZSH_MAX_ARRAY_LENGTH that can be set to 0 to turn it off is probably > } the best. > > I think something based on one of the process limits would be good. > Maybe combined with stashing it in a variable that can be modified. > Maybe even putting that variable in a module so it's not visible in a > barebones shell. > > datasize, stacksize, and addressspace are all candidates for how to > figure out the limit. (Do we ever allocate arrays for zsh parameter > expansion on the stack?) I don't really know how to estimate the array size, however, since it consists of the array length and the size occupied by each element, and it depends what the elements are doing. So the relationship between the limit and the size of the array is very vague, to the point where I'm not sure if it's useful. Nor is it clear to me that basing per-array limits on global limits is useful --- it's only helpful in practice if you've got one, single large array. If you treat as some sort of finger in the air estimate as to how much space the user is likely to be able to cram into an array, I'm still not sure you can do it well enough to make it useful. Furthermore, here are my limits (which, like most users, I haven't touched): cputime unlimited filesize unlimited datasize unlimited stacksize 8MB coredumpsize unlimited memoryuse unlimited maxproc 1024 descriptors 1024 memorylocked 64kB addressspace unlimited maxfilelocks unlimited sigpending 15927 msgqueue 819200 nice 0 rt_priority 0 The only relevant useful one is stacksize; but array length doesn't have direct implications for the stack. So I don't see anything I personally would be able to implement here, though if anyone else has ideas they're certainly welcome to look. Indeed, given the original intention, is it actually useful to apply the limit to anything other than the argument array? As something to do now, I'd be tempted either to "#if 0" the code until someone can come up with a replacement that is demonstrably useful, or implement $ZSH_MAX_ARRAY_LENGTH and initialise it to 0 (no limit), applying it at the current definitely non-optimal location. Either option at least gives us something basic usable, which the current code isn't really. Anything beyond that still seems to be somewhat ill-defined and I'd like finally to have something non-broken ASAP. -- Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog