all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Chip Coldwell <coldwell@redhat.com>
Subject: Re: seg-fault in unexelf.c
Date: Fri, 21 Jul 2006 16:53:19 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0607211646170.2372@localhost.localdomain> (raw)
In-Reply-To: <Pine.LNX.4.64.0607211342320.2372@localhost.localdomain>

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,
> 		  new_data2_size);

[ ... ]

> 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
> seg-faults.

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

signal(SIGSEGV, SIG_IGN);

before the memcpy and

signal(SIGSEGV, SIG_DFL);

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

Chip

-- 
Charles M. "Chip" Coldwell
Senior Software Engineer
Red Hat, Inc
978-392-2426

  reply	other threads:[~2006-07-21 20:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-21 17:59 seg-fault in unexelf.c Chip Coldwell
2006-07-21 20:53 ` Chip Coldwell [this message]
2006-07-22  0:33 ` Nick Roberts
2006-07-22 12:37   ` Chip Coldwell
2006-07-22 12:50     ` Nick Roberts
2006-07-22  4:39 ` Richard Stallman
2006-07-22 12:27   ` Chip Coldwell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0607211646170.2372@localhost.localdomain \
    --to=coldwell@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.