bugGNU nano - Bugs: bug #60172, memory leak in...

 
 

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

bug #60172: memory leak in precalc_multicolorinfo()

Submitted by:  Mike Frysinger <vapier>
Submitted on:  Fri 05 Mar 2021 02:15:08 AM UTC  
 
Severity:  3 - Normal Status:  Fixed
Assigned to:  Benno Schulenberg <bens> Open/Closed:  Closed

( Jump to the original submission)

Fri 30 Apr 2021 10:37:18 AM UTC, comment #7: 

The leak fix was released in nano-5.7.  Thanks for reporting.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Fri 05 Mar 2021 05:53:02 PM UTC, comment #6: 

thanks, i wasn't expecting a review of my customizations ;).  the file has been around a long time as you can tell.  i think all my random systems have updated to at least nano-4 at this point, so i can refresh some of these like your keybinding suggestions.

wrt noconvert, i need nano to not corrupt files on me when i open them.  it's not uncommon to get files from people or in source repos that use DOS endings that i need to tweak/fix without mangling the rest of the file (like running a formatter over an entire file before committing it or sending out for review for a single line change).  i also sometimes need to know that it's using ^M gremlins in order to debug weird behavior, and having it show up in the editor nice & bright is helpful.

there's really no situation that i would ever want an editor to do this for me :).  if i need to convert, there's `dos2unix` and such.  i understand that some people like that behavior, so i don't have much of an opinion on the default.  i just need to be able to make sure it's always turned off for me.

i'll start an e-mail thread on the status bar for general discussion.

Mike Frysinger <vapier>
Project Member
Fri 05 Mar 2021 04:20:40 PM UTC, comment #5: 

By the way, from seeing your unbind commands: M-Q nowadays repeats a backward search (instead of toggling tabs-to-spaces), so you might want to not unbind that keystroke?  And M-B in the main menu nowadays invokes the linter (when the syntax defines one), but I can imagine you still want to unbind that one.  And M-N in the main menu toggles line numbers, which might sometimes be useful?

I see you use 'set noconvert'.  May I ask why?  Is it because you want to see the ^M at the end of each line when somehow you open a file in DOS format, so that you have visual feedback, instead of nano auto-converting and showing only short message in the status bar that no one will see unless they pay attention?

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Fri 05 Mar 2021 10:26:48 AM UTC, comment #4: 

Fixed in git, commit 49ca7e5a.  Thanks for reporting.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Fri 05 Mar 2021 10:08:39 AM UTC, comment #3: 

The offending commit is 1fdd23d3: "for a large paste or insertion, recalculate the multiline cache".

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Fri 05 Mar 2021 10:06:48 AM UTC, comment #2: 

Confirmed.  When CFLAGS contains "-fsanitize=address -O0", the leak can be reproduced with:

src/nano +22 doc/faq.html

and then typing: M-T ^U ^X ^N

Result:

==5564==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 44 byte(s) in 22 object(s) allocated from:
    #0 0x7f861b9cbb40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40)
    #1 0x556184e6597e in nmalloc /home/ben/Sources/NANO/src/utils.c:295
    #2 0x556184e03201 in precalc_multicolorinfo /home/ben/Sources/NANO/src/color.c:308
    #3 0x556184e0d864 in prepare_for_display /home/ben/Sources/NANO/src/files.c:503
    #4 0x556184e37039 in main /home/ben/Sources/NANO/src/nano.c:2500
    #5 0x7f861b0c4bf6 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21bf6)

SUMMARY: AddressSanitizer: 44 byte(s) leaked in 22 allocation(s).

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Fri 05 Mar 2021 02:16:52 AM UTC, comment #1: 

the log isn't clear but this is v5.6 as in d7853df8b6e791769ed1b81d679e94becafb8a76

Mike Frysinger <vapier>
Project Member
Fri 05 Mar 2021 02:15:08 AM UTC, original submission:  

$ nano --version
 GNU nano from git, v5.6
 (C) 1999-2011, 2013-2021 Free Software Foundation, Inc.
 (C) 2014-2021 the contributors to nano
 Compiled options: --disable-justify --enable-utf8

$ cat ~/.nanorc
set constantshow
set fill -2
set historylog
unset locking
set positionlog
set morespace
set multibuffer
set noconvert
set nohelp
set nowrap
# set regexp
set smarthome
set smooth
set suspend
set tabsize 4
set whitespace "»·"
set speller "aspell -x -c"

# Disable justify logic.
unbind ^J all
unbind M-J all
unbind F4 all
# Disable various UI interactions.
unbind M-X all # help mode
#unbind M-C all # constant cursor
unbind M-O all # use one more line for editing
unbind M-H all # smart home
unbind M-I all # auto indent
unbind M-Q all # tab/space conversion
unbind M-B main # backup files
unbind M-M all # mouse
unbind M-N all # dos/mac conversion mode

bind M-d cutwordright all

$ ./configure CC=gcc CFLAGS=-O2 -pipe -g -ggdb -march=native -ffile-prefix-map=$(abs_srcdir)= -fsanitize=address,undefined -O0 --prefix=/usr --datadir=/usr/share --sysconfdir=/etc --libdir=/usr/lib64 --bindir=/bin --disable-dependency-tracking --disable-silent-rules --enable-color --enable-multibuffer --enable-nanorc --enable-libmagic --enable-speller --disable-justify --disable-debug --enable-nls --enable-utf8 --disable-tiny

$ gcc --version
gcc (Gentoo 10.2.0-r5 p6) 10.2.0

=================================================================
==5317==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 22 byte(s) in 11 object(s) allocated from:
    #0 0x7ff983c8c5ff in __interceptor_malloc /var/tmp/portage/sys-devel/gcc-10.2.0-r5/work/gcc-10.2.0/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x55c3725f800c in nmalloc /utils.c:295
    #2 0x55c3725576b9 in precalc_multicolorinfo /color.c:308
    #3 0x55c37256b9fe in prepare_for_display /files.c:502
    #4 0x55c3725abfc5 in main /nano.c:2500
    #5 0x7ff983013cfd in __libc_start_main ../csu/libc-start.c:308

SUMMARY: AddressSanitizer: 22 byte(s) leaked in 11 allocation(s).

Mike Frysinger <vapier>
Project Member

 

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)
  •  

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

    Only logged-in users can vote.

     

     

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-04-30 bens Open/ClosedOpen => Closed
    2021-03-05 bens Summarymemory leak from precalc_multicolorinfo => memory leak in precalc_multicolorinfo()
    2021-03-05 bens StatusNone => Fixed
    2021-03-05 bens Assigned toNone => bens

    Back to the top


    Powered by Savane 3.7