From: eplmst AT lu DOT erisoft DOT se (Martin Stromberg) Newsgroups: comp.os.msdos.djgpp Subject: Re: Generating SIGSEGV Date: 27 Sep 1999 10:07:11 GMT Organization: Ericsson Erisoft AB, Sweden Lines: 43 Message-ID: <7snfkf$2p1$1@antares.lu.erisoft.se> References: <7sdnaj$d6h$3 AT news DOT luth DOT se> NNTP-Posting-Host: spica-144.lu.erisoft.se X-Newsreader: TIN [version 1.2 PL2] To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com The solution is to _use_ the value of i, otherwise it's optimised out of the loop. Martin Str|mberg (ams AT ludd DOT luth DOT se) wrote: : Hmm. It's strange, when I really want to make my program crash with : SIGSEGV it seems impossible to achive that. : Here's my test prorgam: : #include : #include : int : a_very_long_function_name_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(void) : { : unsigned long *i_p; : unsigned long i; : for(i_p = NULL; i_p < ULONG_MAX-1000000; i_p += 409600) : { : printf("i_p = 0x%lx.\n", i_p); : i = *i_p; /* Here we use i! Nice SIGSEGV, here it comes. */ printf("i = 0x%ld.\n", i); : } : } : int main(void) : { : a_very_long_function_name_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(); : return(0); : } Right, MartinS