Path: utzoo!telly!attcan!uunet!tut.cis.ohio-state.edu!YAHI.STANFORD.EDU!mdt From: mdt@YAHI.STANFORD.EDU (Michael Tiemann) Newsgroups: gnu.g++.bug Subject: alloca's in ld.c cause seg-faults Message-ID: <8903201714.AA24798@yahi> Date: 20 Mar 89 17:14:22 GMT References: <8903200402.AA26265@maui.cs.ucla.edu> Sender: daemon@tut.cis.ohio-state.edu Reply-To: tiemann@lurch.stanford.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 46 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