GNU bug report logs - #26628
[PATCH] Fix memory leak of cwd string in emacsclient

Previous Next

Package: emacs;

Reported by: Anders Waldenborg <anders <at> 0x63.nu>

Date: Sun, 23 Apr 2017 19:24:01 UTC

Severity: minor

Tags: fixed, patch

Fixed in version 26.1

Done: npostavs <at> users.sourceforge.net

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 26628 in the body.
You can then email your comments to 26628 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#26628; Package emacs. (Sun, 23 Apr 2017 19:24:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Anders Waldenborg <anders <at> 0x63.nu>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 23 Apr 2017 19:24:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Anders Waldenborg <anders <at> 0x63.nu>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Fix memory leak of cwd string in emacsclient
Date: Sun, 23 Apr 2017 21:23:13 +0200
[Message part 1 (text/plain, inline)]
The attached patch fixes a tiny memory leak in emacsclient.
[Message part 2 (text/html, inline)]
[0001-Fix-memory-leak-of-cwd-string-in-emacsclient.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26628; Package emacs. (Mon, 24 Apr 2017 09:24:02 GMT) Full text and rfc822 format available.

Message #8 received at 26628 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Anders Waldenborg <anders <at> 0x63.nu>
Cc: 26628 <at> debbugs.gnu.org
Subject: Re: bug#26628: [PATCH] Fix memory leak of cwd string in emacsclient
Date: Mon, 24 Apr 2017 11:23:26 +0200
On Apr 23 2017, Anders Waldenborg <anders <at> 0x63.nu> wrote:

> * lib-src/emacsclient.c (main): emacsclient retrieves the current
>   working directory using get_current_dir_name which returns a newly
>   allocated string. Make sure this string is freed before exiting.

There is no need to free it since the process exists right away anyway.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26628; Package emacs. (Mon, 24 Apr 2017 16:07:02 GMT) Full text and rfc822 format available.

Message #11 received at 26628 <at> debbugs.gnu.org (full text, mbox):

From: Anders Waldenborg <anders <at> 0x63.nu>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: 26628 <at> debbugs.gnu.org
Subject: Re: bug#26628: [PATCH] Fix memory leak of cwd string in emacsclient
Date: Mon, 24 Apr 2017 18:05:51 +0200
On Mon, Apr 24, 2017 at 11:23:26AM +0200, Andreas Schwab wrote:
> > * lib-src/emacsclient.c (main): emacsclient retrieves the current
> >   working directory using get_current_dir_name which returns a newly
> >   allocated string. Make sure this string is freed before exiting.
> 
> There is no need to free it since the process exists right away anyway.

Yes. Unless you compile with -fsanitize=address and this leak makes
emacsclient mostly unusable as the asan leak checker will change the
return code to non-zero (yes I'm aware that I can set
ASAN_OPTIONS=detect_leaks=0 in the environment).

 anders




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26628; Package emacs. (Thu, 01 Jun 2017 02:59:02 GMT) Full text and rfc822 format available.

Message #14 received at 26628 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: Anders Waldenborg <anders <at> 0x63.nu>, 26628 <at> debbugs.gnu.org
Subject: Re: bug#26628: [PATCH] Fix memory leak of cwd string in emacsclient
Date: Wed, 31 May 2017 22:59:49 -0400
tags 26628 fixed
close 26628 26.1
quit

Andreas Schwab <schwab <at> linux-m68k.org> writes:

> On Apr 23 2017, Anders Waldenborg <anders <at> 0x63.nu> wrote:
>
>> * lib-src/emacsclient.c (main): emacsclient retrieves the current
>>   working directory using get_current_dir_name which returns a newly
>>   allocated string. Make sure this string is freed before exiting.
>
> There is no need to free it since the process exists right away anyway.

On the other hand, it doesn't really hurt to free it either, pushed to
master [1: c221f1466e].

[1: c221f1466e]: 2017-05-31 22:58:30 -0400
  Fix memory leak of cwd string in emacsclient (Bug#26628)
  http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=c221f1466ed7e0f11f142d9cb3c0247b10e511c6




Added tag(s) fixed. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Thu, 01 Jun 2017 02:59:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 26.1, send any further explanations to 26628 <at> debbugs.gnu.org and Anders Waldenborg <anders <at> 0x63.nu> Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Thu, 01 Jun 2017 02:59:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#26628; Package emacs. (Thu, 01 Jun 2017 06:32:01 GMT) Full text and rfc822 format available.

Message #21 received at 26628 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: npostavs <at> users.sourceforge.net
Cc: Anders Waldenborg <anders <at> 0x63.nu>, 26628 <at> debbugs.gnu.org
Subject: Re: bug#26628: [PATCH] Fix memory leak of cwd string in emacsclient
Date: Wed, 31 May 2017 23:30:53 -0700
[Message part 1 (text/plain, inline)]
Generally speaking we don't bother freeing storage just before program exit 
merely to pacify AddressSanitizer, as that makes the program less efficient and 
is contrary to the goal of leak checking which is to increase efficiency. Here, 
though, we can free storage earlier, and this might have a point since the 
storage can get reused. So I installed the attached further patch.

> I'm aware that I can set ASAN_OPTIONS=detect_leaks=0 in the environment

It might not hurt to do that, if only to prevent our hassling with false alarms.
[0001-Free-cwd-when-no-longer-needed.txt (text/plain, attachment)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 29 Jun 2017 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 359 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.