From owner-freebsd-hackers Sun Feb 22 13:11:59 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id NAA12500 for freebsd-hackers-outgoing; Sun, 22 Feb 1998 13:11:59 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from pluto.cpe.ku.ac.th (pluto.cpe.ku.ac.th [158.108.32.69]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id NAA12467 for ; Sun, 22 Feb 1998 13:11:48 -0800 (PST) (envelope-from stt@pluto.cpe.ku.ac.th) Received: from localhost (stt@localhost) by pluto.cpe.ku.ac.th (8.8.7/8.8.7) with SMTP id EAA19531 for ; Mon, 23 Feb 1998 04:12:05 +0700 (ICT) (envelope-from stt@pluto.cpe.ku.ac.th) Date: Mon, 23 Feb 1998 04:12:05 +0700 (ICT) From: Sunthiti Patchararungruang To: hackers@FreeBSD.ORG Subject: Re: Signal 11 problem In-Reply-To: <199802221942.LAA08014@dingo.cdrom.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sun, 22 Feb 1998, Mike Smith wrote: > > Dear Everybody, > > > > I have written a C program which has a function that need 10 > > arguments. I cannot run this program because the signal-11 occured when I > > call this function. However, when I reduce the number of arguments the > > program can be executed without error. I tried to change eliminated > > arguments to check which one causes the error but the program still > > completely operate. Therefore, I conclude that the problem come from stack > > management in FreeBSD. What should I do? > > Debug your program. Oddly enough, there are lots of people using > FreeBSD, and innumerable functions taking more than 10 arguments. > > Your conclusion is bogus; did you really believe that in all these > years, nobody had ever tried this before? > > You should start by applying the debugger (gdb) to your program and the > core file produced when it crashes. If you build your program with the > '-g' flag you will be able to determine the source line on which the > fault occurs. (This may not be the location of the bug itself, of > course.) > Sorry about my useless example. Here is the real problem. I cut it from wu-ftpd 2.4. All variables are proved to be correct. I use FreeBSD2.2.5. sprintf(msg, "%.24s %d %s %d %s %c %s %c %c %s ftp %d %s\n", ctime(&curtime), xfertime, remotehost, byte_count, namebuf, (type == TYPE_A) ? 'a' : 'b', opt_string(options), 'o', anonymous ? 'a' : 'r', anonymous ? guestpw : pw->pw_name, authenticated, authenticated ? authuser : "*" ); However, if I rewrite it as the following, the program now operates correctly. sprintf(tmsg, "%.24s %d %s %d\n", ctime(&curtime), xfertime, remotehost, byte_count ); strcat (tmsg, namebuf); sprintf(msg, "%s %c %s %c %c %s ftp %d %s\n", tmsg, (type == TYPE_A) ? 'a' : 'b', opt_string(options), 'o', anonymous ? 'a' : 'r', anonymous ? guestpw : pw->pw_name, authenticated, authenticated ? authuser : "*" ); Best Regards, Sunthiti Patchararungruang To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message