bugGNU nano - Bugs: bug #46904, memory leak in undo logic

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #46904: memory leak in undo logic

Submitter:  Mike Frysinger <vapier>
Submitted:  Fri 15 Jan 2016 12:50:33 AM UTC
   
 
Severity:  3 - Normal Status:  Fixed
Assigned to:  bens Open/Closed:  Closed

Fri 15 Jan 2016 04:45:37 PM UTC, comment #2: 

Fixed in SVN, r5567.

Benno Schulenberg <bens>
Group administrator
Fri 15 Jan 2016 04:08:27 PM UTC, comment #1: 

Yeah... when a buffer is closed, nothing of the undo stack is freed.  Working on it.  Thanks for the report.

Benno Schulenberg <bens>
Group administrator
Fri 15 Jan 2016 12:50:33 AM UTC, original submission:  

there appears to be a leak in the undo logic.  the more commands you do that trigger the undo logic, the larger the leak.

using svn 5561 here.  built like so:
$ ./configure CFLAGS='-O0 -g -fsanitize-address' --enable-color --enable-multibuffer --enable-nanorc --disable-wrapping-as-root --enable-libmagic --enable-speller --disable-justify --disable-debug --enable-nls --enable-utf8 --disable-tiny --without-slang --with-wordbounds

my ~/.nanorc is (at least multibuffer is needed to reproduce):
set constantshow
set fill -2
set historylog
set positionlog
set morespace
set multibuffer
set noconvert
set nohelp
set nowrap
set smarthome
set smooth
set suspend
set tabsize 4

then i do:
$ truncate -s 0 f g
$ ./src/nano f g
<alt+. to switch to next buffer>
<hold down enter for a while>
<ctrl+o to save>
<ctrl+x to exit>
<ctrl+x to exit>
=================================================================
==6273==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 104 byte(s) in 1 object(s) allocated from:
    #0 0x7f795e2064aa in malloc (/usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0-alpha20150830/libasan.so.2+0x9e4aa)
    #1 0x455e96 in nmalloc /usr/local/src/nano/src/utils.c:386
    #2 0x44bd57 in add_undo /usr/local/src/nano/src/text.c:932
    #3 0x44ab46 in do_enter /usr/local/src/nano/src/text.c:755
    #4 0x42f86e in do_input /usr/local/src/nano/src/nano.c:1730
    #5 0x433ce0 in main /usr/local/src/nano/src/nano.c:2697
    #6 0x7f795d7445ef in __libc_start_main (/lib64/libc.so.6+0x205ef)

Indirect leak of 47944 byte(s) in 461 object(s) allocated from:
    #0 0x7f795e2064aa in malloc (/usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0-alpha20150830/libasan.so.2+0x9e4aa)
    #1 0x455e96 in nmalloc /usr/local/src/nano/src/utils.c:386
    #2 0x44bd57 in add_undo /usr/local/src/nano/src/text.c:932
    #3 0x44ab46 in do_enter /usr/local/src/nano/src/text.c:755
    #4 0x42f86e in do_input /usr/local/src/nano/src/nano.c:1730
    #5 0x433ce0 in main /usr/local/src/nano/src/nano.c:2697
    #6 0x7f795d7445ef in __libc_start_main (/lib64/libc.so.6+0x205ef)

Indirect leak of 462 byte(s) in 462 object(s) allocated from:
    #0 0x7f795e2064aa in malloc (/usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0-alpha20150830/libasan.so.2+0x9e4aa)
    #1 0x455e96 in nmalloc /usr/local/src/nano/src/utils.c:386
    #2 0x455f5c in mallocstrncpy /usr/local/src/nano/src/utils.c:416
    #3 0x455fbe in mallocstrcpy /usr/local/src/nano/src/utils.c:426
    #4 0x44e545 in update_undo /usr/local/src/nano/src/text.c:1160
    #5 0x44b362 in do_enter /usr/local/src/nano/src/text.c:797
    #6 0x42f86e in do_input /usr/local/src/nano/src/nano.c:1730
    #7 0x433ce0 in main /usr/local/src/nano/src/nano.c:2697
    #8 0x7f795d7445ef in __libc_start_main (/lib64/libc.so.6+0x205ef)

SUMMARY: AddressSanitizer: 48510 byte(s) leaked in 924 allocation(s).

that summary count directly correlates to how many times you hit enter.

Mike Frysinger <vapier>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bens (Posted a comment)
  • -email is unavailable- added by vapier (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-02-13 bens Open/ClosedOpen Closed
    2016-01-15 bens StatusIn Progress Fixed
    2016-01-15 bens StatusNone In Progress
        Assigned toNone bens

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code