[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
alloca() causing SEGFAULT in gnu-make
From: |
saju.pillai |
Subject: |
alloca() causing SEGFAULT in gnu-make |
Date: |
Thu, 6 Sep 2001 12:27:20 +0530 (IST) |
Hi,
I got a segfault while using 'make' to zip close to 78,000 Java class
files. Memory allocation was failing during dependency calculations...
Iam including my analysis here .....
The error message :
Finished dependencies of target file `1808429/j1808429.zip'.
Must remake target `1808429/j1808429.zip'.
Got a SIGCHLD; 1 unreaped children.
Reaping losing child 0x0005b190 PID 8859
gmake: *** [manager] Segmentation Fault
Removing child 0x0005b190 PID 8859 from chain.
Failed to remake target file `manager'.
Finished prerequisites of target file `default'.
Giving up on target file `default'.
gmake: Target `default' not remade because of errors.
-- analysis --
$> make -v
GNU Make version 3.76.1
$> uname -a
SunOS ap555sun 5.6 Generic_105181-16 sun4u sparc SUNW,Ultra-80
The segmentation fault was happening when alloca() was failing to
allocate enough memory on the stack. ( I need close to 8MB for the 78000
filenames )
The code where we are tripping is ...
file : commands.c
function : void set_file_variables(register struct file *)
line numbers : 140 - 184 ( segfault in 184 )
>>>>>
/* Compute first the value for $+, which is supposed to contain
duplicate dependencies as they were listed in the makefile. */
for (d = file->deps; d != 0; d = d->next)
plus_len += strlen (dep_name (d))+ 1;
len = plus_len == 0 ? 1 : plus_len;
cp = plus_value = (char *) alloca(len);
qmark_len = plus_len;
--- code ---
--- code ---
/* Compute the values for $^ and $?.*/
cp = caret_value = plus_value; /* Reuse the buffer; it's big
enough. */
len = qmark_len == 0 ? 1 : qmark_len;
qp = qmark_value = (char *) alloca(len); /* -- THIS line trips -- */
<<<<<< -- Here len = 8MB
The segmentation fault is happening because alloca() fails to allocate the
requested memory and segfaults ( i think this is a known bug with alloca
).
Should I use malloc() here instead of alloca()? I could free() just
before function exists. But I am not sure if malloc() will affect in any
adverse way.
I could change my makefile and break up the monster targets into smaller
ones, but these are automatically created makefiles and to change it will
not be an easy task :-(
What would you guy's suggest ?
Cheers
srp
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- alloca() causing SEGFAULT in gnu-make,
saju.pillai <=