From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16064 invoked by alias); 5 Jul 2014 11:12:46 -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: 32840 Received: (qmail 19403 invoked from network); 5 Jul 2014 11:12:40 -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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 Date: Sat, 5 Jul 2014 13:12:33 +0200 From: Vincent Lefevre To: zsh-workers@zsh.org Subject: Re: segmentation fault with {1..1234567} Message-ID: <20140705111233.GA19385@xvii.vinc17.org> Mail-Followup-To: zsh-workers@zsh.org References: <20140704172545.GA29213@xvii.vinc17.org> <140704184036.ZM18558@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <140704184036.ZM18558@torch.brasslantern.com> X-Mailer-Info: http://www.vinc17.net/mutt/ User-Agent: Mutt/1.5.21-6305-vl-r59709 (2013-04-16) On 2014-07-04 18:40:36 -0700, Bart Schaefer wrote: > On Jul 4, 7:25pm, Vincent Lefevre wrote: > } > } With zsh 5.0.5 (Debian/unstable): > } > } $ zsh -c 'echo {1..1234567}' > } zsh: segmentation fault (core dumped) zsh -c 'echo {1..1234567}' > } > } If a failure is expected for any reason, it shouldn't be a crash. > > Whether that expression fails depends entirely on the memory allocation > limitations of the local host. It works fine for me. That's not a memory allocation problem: it fails on a machine with 24GB! > What's the "expected" behavior of the shell when the user requests a > vast amount of memory? How should the shell recover from running out of > memory at any arbitrary point during execution of a command or script? > Is it really helpful to trap the signal and exit *without* dumping core? No, the signal means that it is already too late. You should really check the return code of malloc and so on. If this comes from a command like here, the best thing is to make it fail, e.g. in an interactive shell: $ some_command zsh: out of memory $ with $? being non-zero, and possibly with some details in the message. -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)