Christian Brabandt wrote:

> Hi Bram!
> 
> On Do, 14 Feb 2013, Bram Moolenaar wrote:
> 
> > Any idea why it crashes for you and not for me?
> > Perhaps should run under valgrind.
> 
> No and it doesn't segfault, if I only let test87 run. Problem is, 
> close_buffer() might close curbuf and curbuf can get freed(). Of course 
> then you can't access curbuf->b_p_tw in enter_buffer() anymore.
> 
> Valgrind confirms this:
> 
> ==12456== Memcheck, a memory error detector
> ==12456== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
> ==12456== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
> ==12456== Command: ../vim -u unix.vim -U NONE --noplugin -s dotest.in 
> test49.in
> ==12456== Parent PID: 12450
> ==12456==
> ==12456== Invalid read of size 8
> ==12456==    at 0x40FB67: enter_buffer (buffer.c:1445)
> ==12456==    by 0x40FB51: set_curbuf (buffer.c:1433)
> ==12456==    by 0x40F8FC: do_buffer (buffer.c:1330)
> ==12456==    by 0x40ED18: do_bufdel (buffer.c:872)
> ==12456==    by 0x472768: ex_bunload (ex_docmd.c:5062)
> ==12456==    by 0x46DE03: do_one_cmd (ex_docmd.c:2681)
> ==12456==    by 0x46B3EF: do_cmdline (ex_docmd.c:1122)
> ==12456==    by 0x454E8C: call_user_func (eval.c:22604)
> ==12456==    by 0x43DB87: call_func (eval.c:8484)
> ==12456==    by 0x43D73C: get_func_tv (eval.c:8326)
> ==12456==    by 0x43905E: eval7 (eval.c:5160)
> ==12456==    by 0x4388F7: eval6 (eval.c:4812)
> ==12456==    by 0x438447: eval5 (eval.c:4628)
> ==12456==    by 0x43774E: eval4 (eval.c:4321)
> ==12456==    by 0x437592: eval3 (eval.c:4233)
> ==12456==  Address 0xc68b550 is 5,360 bytes inside a block of size 7,064 
> free'd
> ==12456==    at 0x4C2A739: free (in 
> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==12456==    by 0x4DD924: vim_free (misc2.c:1744)
> ==12456==    by 0x40E983: free_buffer (buffer.c:665)
> ==12456==    by 0x40E5F0: close_buffer (buffer.c:499)
> ==12456==    by 0x40FAE8: set_curbuf (buffer.c:1409)
> ==12456==    by 0x40F8FC: do_buffer (buffer.c:1330)
> ==12456==    by 0x40ED18: do_bufdel (buffer.c:872)
> ==12456==    by 0x472768: ex_bunload (ex_docmd.c:5062)
> ==12456==    by 0x46DE03: do_one_cmd (ex_docmd.c:2681)
> ==12456==    by 0x46B3EF: do_cmdline (ex_docmd.c:1122)
> ==12456==    by 0x454E8C: call_user_func (eval.c:22604)
> ==12456==    by 0x43DB87: call_func (eval.c:8484)
> ==12456==    by 0x43D73C: get_func_tv (eval.c:8326)
> ==12456==    by 0x43905E: eval7 (eval.c:5160)
> ==12456==    by 0x4388F7: eval6 (eval.c:4812)
> ==12456==

I think we should actually move the code to get the old value of
'textwidth' to the caller of enter_buffer().  It might be that there are
only one or two places where this is relevant.  Perhaps it can be
combined with some other option value that might have changed and
require an action after entering another buffer?

-- 
"I love deadlines.  I especially like the whooshing sound they
make as they go flying by."
                         -- Douglas Adams

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Raspunde prin e-mail lui