From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by melb.werple.net.au (8.7.5/8.7.3/2) with ESMTP id IAA07209 for ; Mon, 1 Jul 1996 08:12:45 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id RAA29445; Sun, 30 Jun 1996 17:50:07 -0400 (EDT) Resent-Date: Sun, 30 Jun 1996 17:50:07 -0400 (EDT) From: "Bart Schaefer" Message-Id: <960630145016.ZM12277@candle.brasslantern.com> Date: Sun, 30 Jun 1996 14:50:13 -0700 In-Reply-To: "Bart Schaefer" "Re: bug (?) in 3.0-pre1" (Jun 30, 12:21pm) References: <199606301613.SAA01458@hzoli.ppp.cs.elte.hu> <960630122142.ZM11441@candle.brasslantern.com> Reply-To: schaefer@nbn.com X-Mailer: Z-Mail (4.0b.607 07jun96) To: Zoltan Hidvegi , zsh-workers@math.gatech.edu Subject: Action, not words (Re: bug (?) in 3.0-pre1) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"z1ma_.0._B7.EQlrn"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/1490 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Jun 30, 12:21pm, Bart Schaefer wrote: } Subject: Re: bug (?) in 3.0-pre1 } } By the way, I applied your patch from a couple of messages back on this } thread, and yet I *still* get: } } zagzig[83] cd .. } BUG: permanent allocation in doshfunc } } How many of these are you going to track down before you give up and make } doshfunc() set up heap allocation on its own? Here's a patch that cleans up much of the heapalloc/permalloc mess. What this does is: 1. Rename heapalloc/permalloc/lastalloc as global_heapalloc/et.al. 2. Introduce macros for heapalloc/permalloc that start with an open brace, and a macro for lastalloc that ends with a close brace, so it's syntatically required that every heapalloc/permalloc have a matching lastalloc. As this introduces a new block context, use a block-local variable in heapalloc/permalloc to remember the state of the useheap global, and test the block-local in lastalloc to reset the global state appropriately. (I normally don't approve of that sort of macro game, but in this case it makes more sense than what was there.) 3. Change a number of permalloc/heapalloc calls to lastalloc, so that the block contexts balance. 4. Where it's not possible to balance the contexts, use the global_* calls explicitly. Ideally, the only place that the global_* calls should appear is in main(), so the other uses make it very obvious where potential allocation problem areas exist. 5. Replace two occurrences of MUSTUSEHEAP with two heapalloc/lastalloc pairs. The remaining instances of MUSTUSEHEAP thus also point out problem areas, involving `goto's and functions that have a large number of `return' exit points. For those who consider this too sweeping, here's a shorter patch that fixes only the `BUG: ...' mentioned above: *** Src/builtin.c.0 Fri Jun 28 06:43:49 1996 --- Src/builtin.c Sun Jun 30 14:45:32 1996 *************** *** 956,963 **** heapalloc(); return 1; } - cd_new_pwd(func, dir); heapalloc(); if (stat(unmeta(pwd), &st1) < 0) { zsfree(pwd); --- 956,963 ---- heapalloc(); return 1; } heapalloc(); + cd_new_pwd(func, dir); if (stat(unmeta(pwd), &st1) < 0) { zsfree(pwd); However, I recommend the uuencoded patch below instead. This patch is against 3.0-pre1 with Zoltan's previous patch from this thread already applied. begin 644 alloc.diff M9&EF9B`MG-H+3,N M,"UP2D["B$@("`@(&AE87!A;&QO8R@I.PH@("`@("!I9B`H87)R M87DI"B`@"2\J(&-R96%T92!A;B!A2!W:71H('1H92!S<&5C:69I960@ M96QE;65N=',@*B\*("`)2D*("`)+RH@8W)E871E(&%N(&%RG1R M9'5P*"IAG-FG-FPH@(`EZPH@(`D)<&5R;6%L;&]C*"D["B`@"0EA9&1L:6YK;F]D92AL;V-A;&QI MG1R9'5P*&%S9RT^ M;F%M92DL(&]N("8@?E!-7U)%041/3DQ9*3L**BHJ*BHJ*BHJ*BHJ*BHJ"BHJ M*B`S,3(P+#,Q,C8@*BHJ*@H@("`@("`O*B!E9&ET('1H92!P87)A;65T97(@ M=F%L=64@*B\*("`@("`@<&5R;6%L;&]C*"D["B`@("`@('!UPH@(`EP97)M86QL M;V,H*3L*("`)<'5S:&YO9&4H8G5FB==*2!["B`@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U;7`N"BL@ M"51H92!P86ER(&]F('!O:6YT97)S(&YC86QL;V,@86YD(&%L;&]C(&UA>2!P M;VEN="!T;R!E:71H97(**R`)>F%L;&]C("8@>F-A;&QO8R!O2!Z0HK(`EI M2!F;W(@=&AE('!O;VP@:7,@870@=&AE(&5N9"!O9B!T:&4@;65M;W)Y M('=H:6-H(&UE86YS('1H870**R`)=V4@8V%N(&=I=F4@:70@8F%C:R!T;R!T M:&4@G-H+3,N,"UPG-H+3,N,"UPG-H+3,N,"UP')E MG-H M+3,N,"UP7!E("8@ M3E1?2$5!4"D@)B8@(75S96AE87`I('L*("`):&5A<&%L;&]C*"D["B`@"6X@ M/2`H7-TFQE7VUA:6XN8R!Z MFQE7VUA:6XN8PHJ*BH@>G-H+3,N,"UP MG-H+3,N,"UPFQE*"D["B`@("`@('IL96%C=&EV92`](#`["B`@ M("`@(&%L87)M*#`I.PHA("`@("!H96%P86QL;V,H*3L*("`@("`@>G-FPHM+2T@-#@U+#0Y,2`M+2TM M"B`@("`@('1R87-H>FQE*"D["B`@("`@('IL96%C=&EV92`](#`["B`@("`@ M(&%L87)M*#`I.PHA("`@("!L87-T86QL;V,H*3L*("`@("`@>G-FG-H+3,N,"UP MFQE7VUI'@@/"!A;6)I9RD* M("`)"0D@("`@86UB:6<@/2!X>#L*("`)"2`@("!]"B$@"0EP97)M86QL;V,H M*3L*("`)"6EF("AE;7!T>2AC;61L;"DI"B`@"0D@("`@9F5E<"@I.PH@(`D) M96QS92!I9B`H8VUD(#T]('I?;&ES=&-H;VEC97,@?'P@8VUD(#T]('I?9&5L M971E8VAAPHM+2T@-C4P+#8U-B`M+2TM"B`@"0D):68@*'AX M(#P@86UB:6'@["B`@"0D@("`@?0HA(`D) M;&%S=&%L;&]C*"D["B`@"0EI9B`H96UP='DH8VUD;&PI*0H@(`D)("`@(&9E M97`H*3L*("`)"65LPH@(`EI;G0@;VQD97)R(#T@97)R9FQA9SL*+2`):6YT(&QU:"`]('5S M96AE87`["B`@"B`@"6AE87!A;&QO8R@I.PH@(`EF;2`](&1U<'-TFQE7W1R:6-K>2YC('IS M:"TS+C`M<')E,2UW;W)K+U-R8R]Z;&5?=')I8VMY+F,**BHJ('IS:"TS+C`M M<')E,2]3FQE7W1R:6-K>2YC"49R:2!*=6X@,C@@,#8Z-#,Z-3$@,3DY M-@HM+2T@>G-H+3,N,"UP5]L:6YE*"D["B`@("`@(&1O7W-I M;F=L92@J;65N=6-U"!A9&1E9"!T;R!C;VUP M;&5T92!I;B!A(&)L86YK(&)E='=E96X@=V]R9',@*B\*+2TM(#5]L:6YE*"D["B$@("`@(&QA')E M')EG1R9'5P*'1T*3L* M("`@("`@?0HA("`@("!P97)M86QL;V,H*3L*("`@("`@;&5XG-F'!A;G-I;VXH*2(I.PHM("`@("!P=7-H:&5A<"@I.PH@("`@("!H96%P86QL M;V,H*3L*("`@("`@=FP@/2!N97=L:6YK;&ES="@I.PH@("`@("!SG-H+3,N M,"UPG-H+F@* M*BHJ('IS:"TS+C`M<')E,2]3G-H+F@)1G)I($IU;B`R."`P-CHT,SHU M,B`Q.3DV"BTM+2!ZG-H+F@)4W5N($IU M;B`S,"`Q,CHS,3HR-"`Q.3DV"BHJ*BHJ*BHJ*BHJ*BHJ*@HJ*BH@,3(W,2PQ M,C7!EN 2 Justin William Schaefer Sat May 11 03:43 53/4040 "Happy Birthday"