othar@CS.UCLA.EDU (Othar Hansson) (03/20/89)
In "GNU C++ version 1.34.1 (68k, MIT Syntax) compiled by GNU C version 1.34" on a SUN 3, ... ld++ exits with a segmentation fault when fed source files with large data segments. The fault is caused by an attempt to 'alloca' a large chunk of memory in 'copy_data()' in ld.c bytes = (char *) alloca (entry->header.a_data); if a_data is too big (e.g. 950k) to fit on the call stack, then alloca returns garbage, apparently. Allocating using malloc() (with a corresponding 'free(bytes)') fixes the problem, but alloca is used in similarly dangerous contexts elsewhere. Please don't ask how ugly my program must be to have a data segment of 950k :-) Othar Hansson ( othar@cs.ucla.edu ..!{ucbvax|rutgers}!ucla-cs!othar )
mdt@YAHI.STANFORD.EDU (Michael Tiemann) (03/21/89)
Date: Sun, 19 Mar 89 20:02:45 PST From: othar@cs.ucla.edu (Othar Hansson) Reply-To: othar@cs.ucla.edu Organization: Weapons Division, Pepperidge Farm Physical-Address: 3436 Boelter Hall In "GNU C++ version 1.34.1 (68k, MIT Syntax) compiled by GNU C version 1.34" on a SUN 3, ... ld++ exits with a segmentation fault when fed source files with large data segments. The fault is caused by an attempt to 'alloca' a large chunk of memory in 'copy_data()' in ld.c bytes = (char *) alloca (entry->header.a_data); if a_data is too big (e.g. 950k) to fit on the call stack, then alloca returns garbage, apparently. Allocating using malloc() (with a corresponding 'free(bytes)') fixes the problem, but alloca is used in similarly dangerous contexts elsewhere. Please don't ask how ugly my program must be to have a data segment of 950k :-) Othar Hansson ( othar@cs.ucla.edu ..!{ucbvax|rutgers}!ucla-cs!othar ) This problem may be fixable by doing this: unlimit stacksize Or, do this: limit see what the limit of stacksize is (say 2048K), multiply it by 4, and set a new limit: limit stacksize 8192 Michael
othar@CS.UCLA.EDU (Othar Hansson) (03/21/89)
Date: Mon, 20 Mar 89 09:14:22 PST From: mdt@yahi.stanford.edu (Michael Tiemann) Reply-To: tiemann@lurch.stanford.edu Date: Sun, 19 Mar 89 20:02:45 PST From: othar@cs.ucla.edu (Othar Hansson) ld++ exits with a segmentation fault when fed source files with large data segments. The fault is caused by an attempt to 'alloca' a large chunk of memory in 'copy_data()' in ld.c bytes = (char *) alloca (entry->header.a_data); This problem may be fixable by doing this: unlimit stacksize Or, do this: limit see what the limit of stacksize is (say 2048K), multiply it by 4, and set a new limit: limit stacksize 8192 That did the trick -- "ulimit -s 8192" in ksh. Thanks, Othar