Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* OSF/1 3.0 virt mem failure in C pgm
@ 1994-12-06  1:40 Peter Sherwood
  1994-12-06 13:35 ` Greg Lueck Development Environment
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Sherwood @ 1994-12-06  1:40 UTC (permalink / raw)



The following C program gets a segmentation error. Examination of
the machine code reveals that the function r has a loop which
appears to be reading one quadword per page of array b, which
is allocated on the stack.  The Alpha 3000/300LX on which it
was run has 32 Mbytes of memory. If b is allocated as a global
array, the program doesn't fail. If the size of b is decreased
from 2,000,000 to 200,000, the program doesn't fail, although
the machine code is the same except for the number of pages
read. This looks like an error in the loader or the virtual
memory system, failing to handle page faults for memory in
the stack area. The program is compiled with

cc -O0 -g -c bug08.c
cc bug08.o

Same results (and machine code) if gcc 2.6.0 is used instead
of cc.
-----------------------------------------------------------------------------
Peter Sherwood
(617) 332-8880 (voice)
(617) 332-1675 (fax)
gbcacm@ccs.neu.edu
-----------------------------------------------------------------------------

void r(unsigned long n);

int main(void) {
unsigned long n;
r(n);

return 0;
}

void r(unsigned long n) {
unsigned long b[2000000];

return;
}


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: OSF/1 3.0 virt mem failure in C pgm
  1994-12-06  1:40 OSF/1 3.0 virt mem failure in C pgm Peter Sherwood
@ 1994-12-06 13:35 ` Greg Lueck Development Environment
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Lueck Development Environment @ 1994-12-06 13:35 UTC (permalink / raw)



Your program is not showing a virtual memory bug, but is exceeding the
process's default stack size limit.  By default, a process can have only
2M of stack.  If a process exceeds this limit, the kernel reports an access
violation for the memory reference that causes the stack to grow too big.

You can change the stack size limit from the shell by doing this:

From the csh:

	% limit stacksize unlimited

From the bourne or korn shells:

	$ ulimit -s 32768

You can also change the limit from within the program by using this code
fragment near the beginning:

	#include <sys/resource.h>

	struct rlimit	rlim;

	getrlimit(RLIMIT_STACK, &rlim);
	rlim.rlim_cur = rlim.rlim_max;
	setrlimit(RLIMIT_STACK, &rlim);

-- 
-------------------------------------------------------------------------------
Greg Lueck                              Opinions expressed herein are my own.
lueck@zk3.dec.com
-------------------------------------------------------------------------------
-- 
-------------------------------------------------------------------------------
Greg Lueck                              Opinions expressed herein are my own.
lueck@zk3.dec.com
-------------------------------------------------------------------------------


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1994-12-06 13:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-12-06  1:40 OSF/1 3.0 virt mem failure in C pgm Peter Sherwood
1994-12-06 13:35 ` Greg Lueck Development Environment

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox