nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nano-devel] solving a history bug in nano [patch]


From: Tito
Subject: Re: [Nano-devel] solving a history bug in nano [patch]
Date: Tue, 31 May 2016 14:42:43 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.8.0


On 05/31/2016 10:20 AM, Benno Schulenberg wrote:
> 
> On Mon, May 30, 2016, at 21:20, Tito wrote:
>> On 05/30/2016 05:51 PM, address@hidden wrote:
>>> The value might be converted to a signed int somewhere inside find_history.
> 
> I don't see how -- it gets passed directly to strncmp().
> 
>> Perhaps use the largest value possible that can never be negative?
>>>
>>> #define SIZE_T_HALF_MAX ((~(size_t)0)>>1)
> 
> Tito, did you try using ((~(size_t)0)>>1) instead of (size_t)-1?

Yes works.

>> what I would do is (based on a very superficial look at the code):
>>
>> 1) when reading in search history from a history file set it to
>>      the length of the longest string and not more than  SIZE_T_HALF_MAX
> 
> That means an extra global variable; there shouldn't be any need
> for that.
> 
>> this would avoid in most use cases to waste memory as search strings in
>> my experience are rather short.
> 
> No memory is wasted now.  The (size_t)-1 just means: compare the
> whole strings.  When the strings are stored, they are mallocstrcpy'd,
> so just the required space is allocated.
> 
> Did you try running nano with gdb?  I would still like to know why and
> where it segfaults for you.
> 

Program received signal SIGABRT, Aborted.
0x400c6548 in raise () from /lib/libc.so.6
(gdb) backtrace
#0  0x400c6548 in raise () from /lib/libc.so.6
#1  0x400c7b6c in abort () from /lib/libc.so.6
#2  0x400fe344 in __libc_message () from /lib/libc.so.6
#3  0x4010423c in malloc_printerr () from /lib/libc.so.6
#4  0x401043b8 in malloc_consolidate () from /lib/libc.so.6
#5  0x40106218 in _int_malloc () from /lib/libc.so.6
#6  0x40107878 in malloc () from /lib/libc.so.6
#7  0x00033d30 in nmalloc (howmuch=714) at utils.c:388
#8  0x0003847c in statusbar (msg=0x1 <Address 0x1 out of bounds>) at 
winio.c:2126
#9  0x00028e9c in findnextstr (whole_word_only=false, begin=0xc91a0, begin_x=0, 
needle=0x4e048 "prova", needle_len=0x0)
    at search.c:364
#10 0x000291a8 in do_search () at search.c:456
#11 0x00021544 in do_input (allow_funcs=true) at nano.c:1692
#12 0x000232b8 in main (argc=1, argv=0xbee0b6a4) at nano.c:2652

> Benno
> 
> 

Ciao,
Tito



reply via email to

[Prev in Thread] Current Thread [Next in Thread]