Skip to contentSkip to conversation

ia64 gcc implementation of alloca

Linux-ia64 [email protected] 2 participants 2 messages Jun 6, 2000 – Jun 7, 2000

lore
Share & tools
lore
#0 lore raw

Hi,
Has anyone had any problem using alloca, or knows where in the gcc code it is implemented?
when I run my program get the following error:

Program received signal SIGSEGV, Segmentation fault. loose (code, fd=6, name=0x9ffffffffff05ca0 "libnss_files.so.2",

    realname=0x60000000000115b0 "/lib/libnss_files.so.2", l=0x0,
    msg=0x200000000002f880 "cannot read file data") at dl-load.c:642

642 a[0] = fd;
(gdb)

the code around line 642 is the following
__attribute__ ((noreturn))
lose (int code, int fd, const char *name, char *realname, struct link_map *l,
const char *msg)
{
/* The use of `alloca' here looks ridiculous but it helps. The goal
is to avoid the function from being inlined. There is no official way to do this so we use this trick. gcc never inlines functions which use `alloca'. */
int *a = alloca (sizeof (int));
a[0] = fd;

simple testcases of alloca seem to work, so this is probably an intermittent problem.

Thank you,
Ronen Grosman
- e-mail [email protected]

#1 lore raw

Has anyone had any problem using alloca, or knows where in the gcc code it is implemented?

There is a lot of GNU code that uses alloca. I haven't seen any alloca bug reports.

There are a number of places in gcc that deal with alloca. The main one is allocate_dynamic_stack_space in explow.c.

It is probably easier to debug your failing code before trying to debug gcc. Look at the instruction that failed, disassemble the loose routine, and figure out why you get the segmentation fault. It could be a problem with the code rather than a gcc problem. Is the stack pointer valid? Is it aligned properly, does it point to a valid stack address?

It looks like the program is dying in the dynamic loader when trying to load a shared library. Do you have a reasonably up to date copy of the dynamic loader? Are your shared libraries up to date? There were many reports of problems with glibc failing when a /etc/nsswitch.conf file was present early this year, but it seems to work fine now. The Red Hat May 17, 2000 OS release has the file and it works fine. I suspect a glibc bug that was fixed maybe a month or two ago.

Jim