[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: seg-fault in unexelf.c

From: Chip Coldwell
Subject: Re: seg-fault in unexelf.c
Date: Fri, 21 Jul 2006 16:53:19 -0400 (EDT)

On Fri, 21 Jul 2006, Chip Coldwell wrote:

If I build the temacs binary with no compiler optimization (gcc (GCC)
4.1.0 20060304 (Red Hat 4.1.0-3)), the command above seg-faults in the
unexec function (file unexelf.c) while executing this line:

         memcpy (NEW_SECTION_H (nn).sh_offset + new_base,
                  (caddr_t) OLD_SECTION_H (n).sh_addr,

[ ... ]

The problem is that the Linux kernel has set up the process virtual
memory with a hole in it, and when the memcpy steps into this hole, it

To paraphrase: the memcpy uses the .bss section start address from the
temacs ELF file for the lower bound, and sbrk(0) from the running
temacs process for its upper bound of a copy from the process address
space to the new ELF file .data section it is creating, but the Linux
kernel can set up the process address space such that there are holes
in the virtual address space between these two addresses.  Stepping
into such a hole gets you a segmentation fault.

A colleague suggested that one (crude) way to cope with this would be


before the memcpy and


afterwards, although it might be better to unroll the memcpy to do
just a page at a time if taking this approach.


Charles M. "Chip" Coldwell
Senior Software Engineer
Red Hat, Inc

reply via email to

[Prev in Thread] Current Thread [Next in Thread]