Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Feb 1998 11:42:39 -0800
From:      Mike Smith <mike@smith.net.au>
To:        Sunthiti Patchararungruang <stt@pluto.cpe.ku.ac.th>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: Signal 11 problem 
Message-ID:  <199802221942.LAA08014@dingo.cdrom.com>
In-Reply-To: Your message of "Mon, 23 Feb 1998 00:59:29 %2B0700." <Pine.BSF.3.96.980223003718.18247A-100000@pluto.cpe.ku.ac.th> 

next in thread | previous in thread | raw e-mail | index | archive | help
> Dear Everybody,

Dear plaintiff; please fix your mail headers so that we can respond to 
you.

> 	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 in some mis-syntax of english. I have an example to explain
> the problem

Your syntax is fine, but your example is nonfunctional.  Here is an 
improved example, which compiles and runs just fine.

#include <stdio.h>

int
test(int  a0, int  a1, int  a2, int  a3, int  a4, int  a5, int  a6, int  a7, 
     int a10, int a11, int a12, int a13, int a14, int a15, int a16, int a17,
     int a20, int a21, int a22, int a23, int a24, int a25, int a26, int a27,
     int a30, int a31, int a32, int a33, int a34, int a35, int a36, int a37,
     int a40, int a41, int a42, int a43, int a44, int a45, int a46, int a47,
     int a50, int a51, int a52, int a53, int a54, int a55, int a56, int a57,
     int a60, int a61, int a62, int a63, int a64, int a65, int a66, int a67,
     int a70, int a71, int a72, int a73, int a74, int a75, int a76, int a77)
{
    return(a0 +  a1 +  a2 +  a3 +  a4 +  a5 +  a6 +  a7 +
	   a10 + a11 + a12 + a13 + a14 + a15 + a16 + a17 +
	   a20 + a21 + a22 + a23 + a24 + a25 + a26 + a27 +
	   a30 + a31 + a32 + a33 + a34 + a35 + a36 + a37 +
	   a40 + a41 + a42 + a43 + a44 + a45 + a46 + a47 +
	   a50 + a51 + a52 + a53 + a54 + a55 + a56 + a57 +
	   a60 + a61 + a62 + a63 + a64 + a65 + a66 + a67 +
	   a70 + a71 + a72 + a73 + a74 + a75 + a76 + a77);
}

void
main(void)
{
    printf("Test result : %d\n" ,
	   test(0,  1,  2,  3,  4,  5,  6,  7,
		10, 11, 12, 13, 14, 15, 16, 17,
		20, 21, 22, 23, 24, 25, 26, 27,
		30, 31, 32, 33, 34, 35, 36, 37,
		40, 41, 42, 43, 44, 45, 46, 47,
		50, 51, 52, 53, 54, 55, 56, 57,
		60, 61, 62, 63, 64, 65, 66, 67,
		70, 71, 72, 73, 74, 75, 76, 77));
}

dingo:/tmp>cc -o arg arg.c
dingo:/tmp>./arg 
Test result : 2464

-- 
\\  Sometimes you're ahead,       \\  Mike Smith
\\  sometimes you're behind.      \\  mike@smith.net.au
\\  The race is long, and in the  \\  msmith@freebsd.org
\\  end it's only with yourself.  \\  msmith@cdrom.com



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?199802221942.LAA08014>