From owner-freebsd-hackers@FreeBSD.ORG Wed Jul 6 18:55:41 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 61E1916A41C for ; Wed, 6 Jul 2005 18:55:41 +0000 (GMT) (envelope-from stsp@stsp.in-berlin.de) Received: from einhorn.in-berlin.de (einhorn.in-berlin.de [192.109.42.8]) by mx1.FreeBSD.org (Postfix) with ESMTP id D774343D45 for ; Wed, 6 Jul 2005 18:55:40 +0000 (GMT) (envelope-from stsp@stsp.in-berlin.de) X-Envelope-From: stsp@stsp.in-berlin.de X-Envelope-To: Received: from dice.seeling33.de (e178167200.adsl.alicedsl.de [85.178.167.200]) (authenticated bits=0) by einhorn.in-berlin.de (8.12.10/8.12.10/Debian-4) with ESMTP id j66ItaNK027584 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 6 Jul 2005 20:55:38 +0200 Received: by dice.seeling33.de (Postfix, from userid 1001) id BD94B33C38; Wed, 6 Jul 2005 20:55:36 +0200 (CEST) Date: Wed, 6 Jul 2005 20:55:36 +0200 From: Stefan Sperling To: freebsd-hackers@freebsd.org Message-ID: <20050706185536.GA4700@dice.seeling33.de> Mail-Followup-To: freebsd-hackers@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.1i X-Spam-Score: (-1.602) AWL,BAYES_00,FORGED_RCVD_HELO X-Scanned-By: MIMEDefang_at_IN-Berlin_e.V. on 192.109.42.8 Subject: bus error in strsep X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jul 2005 18:55:41 -0000 Hello hackers, I am getting a bus error in my application when I call strsep and it matches a character. It doesn't matter whether I call the strsep from my libc or a freshly compiled one, the error stays the same. This is my test case: $ cat strsep.c #define NULL ((void*)0) /* copied verbatim from /usr/src/lib/libc/string/strsep.c, * except for the name change */ char * mystrsep(stringp, delim) char **stringp; const char *delim; { char *s; const char *spanp; int c, sc; char *tok; if ((s = *stringp) == NULL) return (NULL); for (tok = s;;) { c = *s++; spanp = delim; do { if ((sc = *spanp++) == c) { if (c == 0) s = NULL; else s[-1] = 0; *stringp = s; return (tok); } } while (sc != 0); } /* NOTREACHED */ } int main(int argc, char* argv[]) { char *c = "whats:your:name:buddy?"; (void*)mystrsep(&c, ":"); } $ gcc -g -o strsep strsep.c $ gdb strsep (gdb) run Starting program: /home/stsp/test/strsep Program received signal SIGBUS, Bus error. 0x080484f2 in mystrsep (stringp=0xbfbfea34, delim=0x80485e6 ":") at strsep.c:26 26 s[-1] = 0; (gdb) print s[-1] $1 = 58 ':' (gdb) When I single step through mystrsep the program works fine. I am running FreeBSD-current from 17th June 2005 on an Athlon-XP, no SMP involved. I can reproduce the error on a dual Celeron box running FreeBSD-5.4-RELEASE with SMP. And I also get the same error with similar code using strtok. Can anyone else reproduce this? thanks a lot, -- stefan http://stsp.in-berlin.de PGP Key: 0xF59D25F0