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

 
 

bug #46904: memory leak in undo logic

Submitted by:  Mike Frysinger <vapier>
Submitted on:  Fri 15 Jan 2016 12:50:33 AM UTC  
 
Severity: 3 - NormalStatus: Fixed
Assigned to: Benno Schulenberg <bens>Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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

Fixed in SVN, r5567.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
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>
Project AdministratorIn charge of this item.
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>
Project Member

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 13 Feb 2016 10:35:39 AM UTCbensOpen/ClosedOpen=>Closed
    Fri 15 Jan 2016 04:45:37 PM UTCbensStatusIn Progress=>Fixed
    Fri 15 Jan 2016 04:08:27 PM UTCbensStatusNone=>In Progress
      Assigned toNone=>bens

    Back to the top


    Powered by Savane 3.1-cleanup1