From owner-freebsd-bugs Wed Feb 6 11:48:43 2002 Delivered-To: freebsd-bugs@freebsd.org Received: from ws1-1.us4.outblaze.com (205-158-62-49.outblaze.com [205.158.62.49]) by hub.freebsd.org (Postfix) with SMTP id AF1E837B422 for ; Wed, 6 Feb 2002 11:48:37 -0800 (PST) Received: (qmail 3750 invoked by uid 1001); 6 Feb 2002 19:48:37 -0000 Message-ID: <20020206194837.3749.qmail@mail.com> Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-Mailer: MIME-tools 5.41 (Entity 5.404) Received: from [65.81.245.188] by ws1-1.us4.outblaze.com with http for keoki@techie.com; Wed, 06 Feb 2002 14:48:37 -0500 From: "keoki smith" To: freebsd-bugs@FreeBSD.ORG Cc: keoki@techie.com Date: Wed, 06 Feb 2002 14:48:37 -0500 X-Originating-Ip: 65.81.245.188 X-Originating-Server: ws1-1.us4.outblaze.com Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org A problem exist in FreeBSD's version of SED, that when you specify last line and do not get contents of hold area and then delete the first part of a pattern space against a file which contains two lines or more, it results in a Segmentation fault "coredump". This is the following two instructions explained above. sed '$!g; D' file And "file" containing two or more lines. When you specify last line and GET the contents of the hold area and then delete the first part of the pattern space, it results in a Segmentation fault as well. Which is the following two instructions, sed '$g; D' file [keoki@jeff:~/test] for i in 1 2; do echo "blah" >> example; done [keoki@jeff:~/test] sed '$!g; D' example Segmentation fault (core dumped) [keoki@jeff:~/test] sed '$g; D' example Segmentation fault (core dumped) [keoki@jeff:~/test] Then I get the following using gdb on sed.core [keoki@jeff:~/test] gdb sed sed.core #0 0x280da416 in memmove () from /usr/lib/libc.so.4 (gdb) Then at address 0x280da416, which is 0x280da416 : repz movsl %ds:(%esi),%es:(%edi) I believe the problem resides in proccess.c Which is located in /usr/src/usr.bin/sed/ and at line 145 of proccess.c, which is memmove(ps, p + 1, psl); in the following case statement, case 'D': if (pd) goto new; if ((p = memchr(ps, '\n', psl - 1)) == NULL) { pd = 1; goto new; } else { psl -= (p + 1) - ps; memmove(ps, p + 1, psl); goto top; } I haven't tested on NetBSD or openBSD's version of sed. I only have tested on FreeBSD. Also note, sed != gsed. And this problem doesn't exist in gsed, which is what most linux distros afaik use as "sed". -- keoki http://sleek.cyberarmy.com -- _______________________________________________ Sign-up for your own FREE Personalized E-mail at Mail.com http://www.mail.com/?sr=signup Win a ski trip! http://www.nowcode.com/register.asp?affiliate=1net2phone3a To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message