|
From: | Ken Brown |
Subject: | bug#9273: 23.3; malloc initialization should (sometimes) happen at runtime |
Date: | Tue, 09 Aug 2011 16:09:48 -0400 |
User-agent: | Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 |
Here's what happens on Cygwin. temacs (on Cygwin) uses a static buffer as its heap and a function bss_sbrk that simulates sbrk. (See src/sheap.c.) The data in this buffer, including malloc information, are then dumped into emacs.exe as initialized data. But when the dumped emacs is run, it uses Cygwin's sbrk, which allocates memory on a heap that won't (as of Cygwin 1.7.10) be contiguous with the static heap. The saved value of _heapbase, which points into the static heap, is never changed, but it will mess up later calculations as soon as sbrk is called for the first time.
All of this is described in detail on the Cygwin mailing list in the thread starting at
http://cygwin.com/ml/cygwin/2011-08/msg00153.html See especially http://cygwin.com/ml/cygwin/2011-08/msg00193.htmlwhich contains a gdb session illustrating the problem. The context for that session is that, as a result of the problem I'm reporting, morecore_nolock went into an infinite loop. I attached gdb to that looping process.
Maybe the solution is for emacs to do malloc initialization, including the assignment of _heapbase, every time it starts, at least on systems that use gmalloc.c. I made one naive attempt to do this, but it didn't work (and it was Cygwin specific). Namely, I made unexec (for Cygwin) set _malloc_initialized = 0 before dumping. The resulting emacs aborted as soon as it was started. I haven't figured out what went wrong, but I'm not sure that's the right answer anyway.
Ken
[Prev in Thread] | Current Thread | [Next in Thread] |