From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.org!not-for-mail
From: Eli Zaretskii <eliz@gnu.org>
Newsgroups: gmane.emacs.bugs
Subject: bug#16901: 24.3.50; emacs_backtrace.txt
Date: Tue, 04 Mar 2014 19:37:15 +0200
Message-ID: <8361ntsw50.fsf@gnu.org>
References: <b93ed3b6-293d-44cd-959a-3933ccb4bcae@default>
	<831tylvkq2.fsf@gnu.org>
	<CAAeL0SRk9UcAWk2rG-8zMspSn94LRnn4cXrc_iJbPt84cgRLOQ@mail.gmail.com>
	<83lhwstu1k.fsf@gnu.org> <83ppm3rznz.fsf@gnu.org>
	<53150E29.7080504@cornell.edu> <83iorusk3h.fsf@gnu.org>
	<5315E1EB.8060404@cornell.edu>
Reply-To: Eli Zaretskii <eliz@gnu.org>
NNTP-Posting-Host: plane.gmane.org
X-Trace: ger.gmane.org 1393954694 12977 80.91.229.3 (4 Mar 2014 17:38:14 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 4 Mar 2014 17:38:14 +0000 (UTC)
Cc: 16901@debbugs.gnu.org, lekktu@gmail.com, dmantipov@yandex.ru
To: Ken Brown <kbrown@cornell.edu>
Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Mar 04 18:38:21 2014
Return-path: <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org>
Envelope-to: geb-bug-gnu-emacs@m.gmane.org
Original-Received: from lists.gnu.org ([208.118.235.17])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org>)
	id 1WKtIL-0002oU-2n
	for geb-bug-gnu-emacs@m.gmane.org; Tue, 04 Mar 2014 18:38:21 +0100
Original-Received: from localhost ([::1]:47033 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org>)
	id 1WKtIK-0004Vn-O1
	for geb-bug-gnu-emacs@m.gmane.org; Tue, 04 Mar 2014 12:38:20 -0500
Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41762)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1WKtIC-0004Ol-1Q
	for bug-gnu-emacs@gnu.org; Tue, 04 Mar 2014 12:38:17 -0500
Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1WKtI3-0004wh-66
	for bug-gnu-emacs@gnu.org; Tue, 04 Mar 2014 12:38:11 -0500
Original-Received: from debbugs.gnu.org ([140.186.70.43]:49396)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1WKtI3-0004wb-3c
	for bug-gnu-emacs@gnu.org; Tue, 04 Mar 2014 12:38:03 -0500
Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80)
	(envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1WKtI2-0001fw-5V
	for bug-gnu-emacs@gnu.org; Tue, 04 Mar 2014 12:38:02 -0500
X-Loop: help-debbugs@gnu.org
Resent-From: Eli Zaretskii <eliz@gnu.org>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@gnu.org
Resent-Date: Tue, 04 Mar 2014 17:38:02 +0000
Resent-Message-ID: <handler.16901.B16901.13939546546385@debbugs.gnu.org>
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: followup 16901
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: moreinfo
Original-Received: via spool by 16901-submit@debbugs.gnu.org id=B16901.13939546546385
	(code B ref 16901); Tue, 04 Mar 2014 17:38:02 +0000
Original-Received: (at 16901) by debbugs.gnu.org; 4 Mar 2014 17:37:34 +0000
Original-Received: from localhost ([127.0.0.1]:50578 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
	id 1WKtHY-0001er-90
	for submit@debbugs.gnu.org; Tue, 04 Mar 2014 12:37:32 -0500
Original-Received: from mtaout23.012.net.il ([80.179.55.175]:59713)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <eliz@gnu.org>) id 1WKtHU-0001eh-2L
	for 16901@debbugs.gnu.org; Tue, 04 Mar 2014 12:37:29 -0500
Original-Received: from conversion-daemon.a-mtaout23.012.net.il by
	a-mtaout23.012.net.il (HyperSendmail v2007.08) id
	<0N1X00J009T19D00@a-mtaout23.012.net.il> for 16901@debbugs.gnu.org;
	Tue, 04 Mar 2014 19:37:26 +0200 (IST)
Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout23.012.net.il
	(HyperSendmail v2007.08) with ESMTPA id
	<0N1X00JOPAAE8K30@a-mtaout23.012.net.il>;
	Tue, 04 Mar 2014 19:37:26 +0200 (IST)
In-reply-to: <5315E1EB.8060404@cornell.edu>
X-012-Sender: halo1@inter.net.il
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x
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" <bug-gnu-emacs.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-gnu-emacs>,
	<mailto:bug-gnu-emacs-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-gnu-emacs>
List-Post: <mailto:bug-gnu-emacs@gnu.org>
List-Help: <mailto:bug-gnu-emacs-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-gnu-emacs>,
	<mailto:bug-gnu-emacs-request@gnu.org?subject=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:86542
Archived-At: <http://permalink.gmane.org/gmane.emacs.bugs/86542>

> Date: Tue, 04 Mar 2014 09:23:39 -0500
> From: Ken Brown <kbrown@cornell.edu>
> CC: lekktu@gmail.com, 16901@debbugs.gnu.org, dmantipov@yandex.ru
> 
> On 3/3/2014 10:45 PM, Eli Zaretskii wrote:
> >> Date: Mon, 03 Mar 2014 18:20:09 -0500
> >> From: Ken Brown <kbrown@cornell.edu>
> >> CC: 16901@debbugs.gnu.org, dmantipov@yandex.ru
> >>
> >> If adj == 0 in line 1596, then we've allocated much more memory than
> >> we needed, and the next call to malloc (line 1602) allocates even
> >> more.  And if adj == 1 in line 1596, then we've allocated exactly as
> >> much memory as we needed, so there's no need to call malloc again in
> >> line 1602.
> >
> > Thanks for reviewing.
> >
> > These are further optimizations, and can (and probably should) be done
> > in separate commits.

Now done in trunk revision 16661.

> > But you aren't saying that the previous code was correct, are you?
> 
> No, I think it was clearly wrong.  By accident, however, it probably 
> worked most of the time and didn't waste memory, since adj is usually 0.

Yes, when the initial allocation was already aligned, it worked OK.

> When/if you do the optimizations I suggested, I think it would clarify 
> the code if `adj' were used to represent the actual adjustment needed, 
> something like this:
> 
>    adj = (uintptr_t) alignment - result % alignment;
>    if (adj == alignment)
>      adj = 0;

I didn't make this change, but feel free to follow up.

Thanks.