Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin-developers AT sources DOT redhat DOT com Date: Thu, 22 Mar 2001 23:52:24 +0300 From: Egor Duda X-Mailer: The Bat! (v1.45) Personal Reply-To: Egor Duda Organization: DEO X-Priority: 3 (Normal) Message-ID: <15325749005.20010322235224@logos-m.ru> To: Egor Duda CC: cygwin-apps AT cygwin DOT com Subject: bug in ash (Was: State of the DLL, mark 2?) In-reply-To: <1983285237.20010321133832@logos-m.ru> References: <20010319203650 DOT A30559 AT redhat DOT com> <907012433 DOT 20010320162719 AT logos-m DOT ru> <20010320091254 DOT F32706 AT redhat DOT com> <2710465067 DOT 20010320172451 AT logos-m DOT ru> <20010320101715 DOT K32706 AT redhat DOT com> <1983285237 DOT 20010321133832 AT logos-m DOT ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi! Wednesday, 21 March, 2001 Egor Duda deo AT logos-m DOT ru wrote: ED> well, i've managed to build it with -DMALLOC_PROVIDED, though it was a ED> bit tricky, and it turned out that cygwin1.dll is not the one to ED> blame. i fear that it's bug in ash -- it fails to evaluate complex ED> expressions. well, i've found the reason. moreover, i've found that as was once patched to fix this bug, but later, patch was reverted. i wonder why. did it have some ill side effects? ============================================================================= Thu Oct 12 14:28:00 2000 Corinna Vinschen * memalloc.c: Revert previous patch until it's need is proved. Tue Oct 10 16:46:00 2000 Corinna Vinschen Patch suggested by Andy Mortimer : * memalloc.c: Add member `refcnt' to struct stack_block. (stalloc): Initialize refcnt when allocating a new block. (setstackmark): Increment refcnt when reusing a stack block. (popstackmark): Decrement refcnt when dropping usage of a stack block. (growstackblock): Reallocate a block only if it's used only once. ========================================================================= the proof of necessity of this patch is following: ash sometimes marks a points on its internal stack via setstackmark and later restores to saved state via popstackmark. "state" is simply a pointer to the record on top of the stack. everythink works fine, until substitutions are small enough to fit into 504 bytes of stack record. but if it don't fit, we call growstackblock. it reallocates stack record, and that means that mark pointer saved earlier no longer points to stack record. so when we call popstackmark it frees all stack, hits the bottom and calls free(stackbase), while stackbase is a static variable. If Andy's patch is wrong, i think i can propose another way -- to divide stack_block into two separately dynamically allocated parts: one of prev and data pointers, and other to contain all data. so we will realloc () only the latter while saving "mark pointers" only to the former. Corinna, should i submit a patch or you'll reapply Andy's one? Egor. mailto:deo AT logos-m DOT ru ICQ 5165414 FidoNet 2:5020/496.19