From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8406 invoked by alias); 13 Apr 2017 15:21:32 -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: 40963 Received: (qmail 13946 invoked from network); 13 Apr 2017 15:21:32 -0000 X-Qmail-Scanner-Diagnostics: from mail-wr0-f170.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.128.170):SA:0(-2.6/5.0):. Processed in 1.375697 secs); 13 Apr 2017 15:21:32 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: arkanosis@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.128.170 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=oXf09Yl8KORI0slbEvYlXrQo1nE4fBOIlmhSUccS1yU=; b=GQne4RVnbJ58ldVQKBCEbeB7J7j4rc3UlZH3bQNAs0EAvDuGVTd0spQB3aJj96Kdyg k9aQIWxqedifdY8tbxIMqqGHnLCj/5MDr1GQqtaAkKwG6PF9D5ASBuODDA5QHNaF9hb2 /IyDmrH5ab0MpNZ7Z1eXsqWu2I3QqN2nOgrVAMRX17FiTtxR1mKehSYsrv4ynHh60x1n fQjHMTgUlCTeNQ9LCGkvvrMsodWtcyHLgtZHwvhZJ9+sWTVT382UI0Tri0ifTxJ+S4sF H1bNoLNc8V4huDFqfysxuAViWzhxzKAaZXgSerT5ZWywQJmIH9YDgIhhrhiOITf8bdne No6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-transfer-encoding; bh=oXf09Yl8KORI0slbEvYlXrQo1nE4fBOIlmhSUccS1yU=; b=IrC74KN9E0UGEEVr/isuo3hSr5Cb2kT817P3rXVO3Al5CF1IV9TB+gx226mrBZ2f/9 2SQ4pOHHYNwQPCBfSP9VcGiMMCabp3X+e4ofsJj5Es6n/6GoVqlxF0EMIFWIotOfDmBF Xv/ZQsEzMf8P3f/FCylhKNtQQspmIwlaZXsfinL0BCf2OGqBaiFEn9wt1zhD55J8iiGW D+BKoTSnGjZEo9AhFWKHLt6fuy3OKyyQ25iD5+Rr3+fyQZQ19fKvRrT7q2OS7+zzBI8b /mxis0KZJADIGhbV/XJCmI+RaFAjAcl1J7V0xGBRwYk0f6BJMq6vhnYj5WLwKCA2F57b aZUQ== X-Gm-Message-State: AN3rC/510C7oEFeQzuR16rgRG5fK7v9+RYJf4a1n3aKlqAU+R9T8/DHG Dw5QoYApNPvb1fDo9yKIWn8RLbvM5S53 X-Received: by 10.223.128.99 with SMTP id 90mr3515540wrk.101.1492096883936; Thu, 13 Apr 2017 08:21:23 -0700 (PDT) MIME-Version: 1.0 Sender: arkanosis@gmail.com In-Reply-To: <2350280.olGvC23INb@kdudka-nb> References: <2960832.nVDpiBkaWZ@kdudka-nb> <2420758.31stuSQeAV@kdudka-nb> <2350280.olGvC23INb@kdudka-nb> From: =?UTF-8?B?SsOpcsOpbWllIFJvcXVldA==?= Date: Thu, 13 Apr 2017 17:21:08 +0200 X-Google-Sender-Auth: N7Ivw0zUcaGQXSFiYsnDI21O0DQ Message-ID: Subject: Re: unbounded recursive call in a shell script crashes zsh To: Kamil Dudka Cc: Bart Schaefer , "zsh-workers@zsh.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2017-04-13 16:30 GMT+02:00 Kamil Dudka : > I was trying to reduce the stack usage of zsh but was not really successf= ul, > mainly because I do not know how to efficiently find the automatic variab= les > that consumed the biggest portion of the stack. [=E2=80=A6] Do you have = any > estimation about where else the stack allocation could be reduced? We get some useful information if we link without the =E2=80=9C-s=E2=80=9D = flag (and it can help to compile with =E2=80=9C-O0 -ggdb=E2=80=9D as well). Then, using gdb's =E2=80=9Cbacktrace=E2=80=9D we get that the stack is bein= g consumed by recursion throught the following 13 frames: #18596 0x0000000000464733 in execif (state=3D0x7fffffffc9f0, do_exec=3D0) at loop.c:572 #18597 0x00000000004360e8 in execcmd_exec (state=3D0x7fffffffc9f0, eparams=3D0x7fffffffc5e0, input=3D0, output=3D0, how=3D18, last1=3D2) at exec.c:3705 #18598 0x00000000004307ea in execpline2 (state=3D0x7fffffffc9f0, pcode=3D67, how=3D18, input=3D0, output=3D0, last1=3D0) at exec.c:1872 #18599 0x000000000042f505 in execpline (state=3D0x7fffffffc9f0, slcode=3D13314, how=3D18, last1=3D0) at exec.c:1602 #18600 0x000000000042e859 in execlist (state=3D0x7fffffffc9f0, dont_change_job=3D1, exiting=3D0) at exec.c:1360 #18601 0x000000000042df2f in execode (p=3D0x7019e0, dont_change_job=3D1, exiting=3D0, context=3D0x4ba7a8 "shfunc") at exec.c:1141 #18602 0x000000000043ae92 in runshfunc (prog=3D0x7019e0, wrap=3D0x0, name=3D0x7ffff7fe7028 "foo") at exec.c:5675 #18603 0x000000000043a763 in doshfunc (shfunc=3D0x701a70, doshargs=3D0x7ffff7ff2568, noreturnval=3D0) at exec.c:5539 #18604 0x000000000043979f in execshfunc (shf=3D0x701a70, args=3D0x7ffff7ff2568) at exec.c:5113 #18605 0x00000000004362c3 in execcmd_exec (state=3D0x7fffffffd830, eparams=3D0x7fffffffd420, input=3D0, output=3D0, how=3D18, last1=3D1) at exec.c:3757 #18606 0x00000000004307ea in execpline2 (state=3D0x7fffffffd830, pcode=3D131, how=3D18, input=3D0, output=3D0, last1=3D1) at exec.c:1872 #18607 0x000000000042f505 in execpline (state=3D0x7fffffffd830, slcode=3D3074, how=3D18, last1=3D1) at exec.c:1602 #18608 0x000000000042e859 in execlist (state=3D0x7fffffffd830, dont_change_job=3D0, exiting=3D1) at exec.c:1360 And using gdb's =E2=80=9Cinfo frame=E2=80=9D on each frame and looking at = =E2=80=9Cframe at=E2=80=9D and =E2=80=9Ccalled by frame at=E2=80=9D, we get: execlist: 416 bytes execpline: 464 bytes execpline2: 208 bytes execcmd_exec: 1056 bytes execshfunc: 336 bytes doshfunc: 736 bytes runshfunc: 336 bytes execode: 96 bytes execlist: 416 bytes execpline: 464 bytes execpline2: 208 bytes execcmd_exec: 1056 bytes execif: 64 bytes If we aggregate, it gives us: execcmd_exec: 2112 bytes execpline: 928 bytes execlist: 832 bytes doshfunc: 736 bytes execpline2: 416 bytes execshfunc: 336 bytes runshfunc: 336 bytes execode: 96 bytes execif: 64 bytes Hence a total of 5856 bytes per recursion, or 5719 kiB for 10000 recursions= . Best regards, --=20 J=C3=A9r=C3=A9mie