From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f9e16,705c8af00836adad X-Google-Attributes: gidf9e16,public X-Google-Thread: f678f,705c8af00836adad X-Google-Attributes: gidf678f,public From: Jeff Sullivan Subject: Re: PATGEN performance problem on Digital UNIX Date: 2000/03/21 Message-ID: <38D79963.420E8897@zk3.dec.com>#1/1 X-Deja-AN: 600438501 Content-Transfer-Encoding: 7bit References: <8atbr0$ao7$1@news.tue.nl> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@mailint03.im.hou.compaq.com X-Trace: mailint03.im.hou.compaq.com 953653614 18596 16.141.0.178 (21 Mar 2000 15:46:54 GMT) Organization: Compaq Computer Corporation Mime-Version: 1.0 NNTP-Posting-Date: 21 Mar 2000 15:46:54 GMT Newsgroups: comp.unix.osf.misc,comp.text.tex This looks like a source code problem in the patgen problem. What is happening is that the stack is being corrupted by a call to the null_terminate routine. A later call to exit() ends up in an rendom loop doing "free"s of bad addresses. This loop is what is consuming most of the time in the bad case. I used atom third degree (see man atom, man third) to diagnose the memory overwrite. This is what it told me when I ran it: strpascal.c: 25: reading invalid heap at 0x140460000 null_terminate patgen, strpascal.c, line 25 make_c_string patgen, strpascal.c, line 15 xfopen_pas patgen, xfopen-pas.c, line 15 dodictionary patgen, patgen2.c, line 1398 main_body patgen, patgen2.c, line 1698 main patgen, main.c, line 30 __start patgen When I ran this in the debugger, I found that there were many calls to make_c_string and did not quickly find where the problem was occuring. However, when I made a simple "debugging" change to null_terminate. I saw this (bad) case: null_terminate: s=pattmp.5, len=8 null_terminate: i=528 In a "good" case, I expect that i would be len-1. It certainly is not in this case. The debugging change I made to null_terminate was this: int i = 0; printf("null_terminate: s=%s, len=%d\n", s, strlen(s)); while (*s != ' ') { s++; i++; } printf("null_terminate: i=%d\n", i); In the (bad) case of pattmp.5, it looks like the string does NOT have a trailing space and the null_terminate function will add the NULL termination to some unknown location. It may sometimes work, but it looks like a source code bug to me. Let me know if this helps. Thanks, -Jeff -- Jeff Sullivan | Compaq Computer Corp. | mailto:jps@zk3.dec.com Compaq C/C++ | Nashua, NH 03062-2698 | Jeff.Sullivan@compaq.com