From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ken Brown Newsgroups: gmane.emacs.bugs Subject: bug#9273: 23.3; malloc initialization should (sometimes) happen at runtime Date: Sat, 13 Aug 2011 09:48:52 -0400 Message-ID: <4E4680C4.6040605@cornell.edu> References: <4E41940C.2010605@cornell.edu> <83zkjhxnty.fsf@gnu.org> <4E444D85.4090907@cornell.edu> <838vqzxgq1.fsf@gnu.org> <4E44FC1B.9010207@cornell.edu> <831uwqyidi.fsf@gnu.org> <4E451A1F.4060409@cornell.edu> <4E458BF4.9080108@cornell.edu> <83fwl5wxbz.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1313243390 19306 80.91.229.12 (13 Aug 2011 13:49:50 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 13 Aug 2011 13:49:50 +0000 (UTC) Cc: "9273@debbugs.gnu.org" <9273@debbugs.gnu.org> To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Aug 13 15:49:40 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QsEao-0002cZ-9Q for geb-bug-gnu-emacs@m.gmane.org; Sat, 13 Aug 2011 15:49:38 +0200 Original-Received: from localhost ([::1]:33702 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QsEan-00067k-Ka for geb-bug-gnu-emacs@m.gmane.org; Sat, 13 Aug 2011 09:49:37 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:52309) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QsEaj-000678-R5 for bug-gnu-emacs@gnu.org; Sat, 13 Aug 2011 09:49:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QsEai-00061Y-OJ for bug-gnu-emacs@gnu.org; Sat, 13 Aug 2011 09:49:33 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:33153) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QsEai-00061M-Mm for bug-gnu-emacs@gnu.org; Sat, 13 Aug 2011 09:49:32 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QsEcA-0007Wj-MF; Sat, 13 Aug 2011 09:51:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ken Brown Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 13 Aug 2011 13:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9273 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 9273-submit@debbugs.gnu.org id=B9273.131324345028915 (code B ref 9273); Sat, 13 Aug 2011 13:51:02 +0000 Original-Received: (at 9273) by debbugs.gnu.org; 13 Aug 2011 13:50:50 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QsEbw-0007WJ-T4 for submit@debbugs.gnu.org; Sat, 13 Aug 2011 09:50:49 -0400 Original-Received: from granite1.mail.cornell.edu ([128.253.83.141] helo=authusersmtp.mail.cornell.edu) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QsEbp-0007W6-QI for 9273@debbugs.gnu.org; Sat, 13 Aug 2011 09:50:44 -0400 Original-Received: from [192.168.1.96] (c-76-118-2-147.hsd1.ma.comcast.net [76.118.2.147]) (authenticated bits=0) by authusersmtp.mail.cornell.edu (8.14.4/8.12.10) with ESMTP id p7DDn8DA012864 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 13 Aug 2011 09:49:09 -0400 (EDT) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0 In-Reply-To: <83fwl5wxbz.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sat, 13 Aug 2011 09:51:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:50046 Archived-At: On 8/13/2011 4:05 AM, Eli Zaretskii wrote: >> Date: Fri, 12 Aug 2011 16:24:20 -0400 >> From: Ken Brown >> CC: "9273@debbugs.gnu.org"<9273@debbugs.gnu.org> >> >> Program received signal SIGSEGV, Segmentation fault. >> 0x006368f5 in _realloc_internal_nolock (ptr=0x897040, size=28) >> at gmalloc.c:1394 >> 1394 type = _heapinfo[block].busy.type; >> (gdb) p block >> $1 = 4294838425 > > I'm confused: since you patched unexecw.c to set __malloc_initialized > to zero, the dumped Emacs should have called malloc_initialize_1, > which should have allocated a new copy of _heapinfo, that was supposed > to be consistent with the current heap. Why isn't that working? why > `block' still gets a value that is relative to the "old" _heapinfo? _heapinfo is indeed consistent with the current heap. But the pointer that was passed to realloc points into the old heap. So applying BLOCK to that pointer yields an absurd result. I can easily catch such cases by testing for ptr < _heapbase, as in my patch to _free_internal_nolock, but I have to figure out the best way to handle them once I've caught them. I have work in progress that tries to keep track of both heaps, but I haven't got it working yet. An alternative would be to have realloc return NULL (or some other special value) in these cases, but then I would have to find all possible callers of realloc (with pointers to the old heap) and make sure they know how to deal with that return value. I'm guessing my first approach is safer and easier to implement. Ken