Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Feb 1998 16:55:57 -0500 (EST)
From:      "John S. Dyson" <toor@dyson.iquest.net>
To:        stt@TCP (Sunthiti Patchararungruang)
Cc:        hackers@FreeBSD.ORG
Subject:   Re: Signal 11 problem
Message-ID:  <199802222155.QAA10038@dyson.iquest.net>
In-Reply-To: <Pine.BSF.3.96.980223040539.19496C-100000@pluto.cpe.ku.ac.th> from Sunthiti Patchararungruang at "Feb 23, 98 04:12:05 am"

next in thread | previous in thread | raw e-mail | index | archive | help

Take a look at 'byte_count.'  It is of type off_t which is a long long.
You need to use %qd for items of type 'long long'.  Since *BSD supports
files > 4GB, that was a needed change.  Many other OSes don't support
large files, and therefore this is a minor compatibility nit that one
often needs to be aware of.


Sunthiti Patchararungruang said:
> 
> 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
> 


-- 
John                  | Never try to teach a pig to sing,
dyson@freebsd.org     | it just makes you look stupid,
jdyson@nc.com         | and it irritates the pig.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199802222155.QAA10038>