Bjorn Winckler wrote:
> A MacVim user ran into a bug using :vimgrep as reported here: > > http://tinyurl.com/kqg2fm > > The bug has been reproduced with 7.2.234 but not in 7.2.148. I can > reproduce with the following steps: > > 1. open Vim, cd to root dir of Vim sources > 2. :vimgrep FEAT_EVAL **/* > 3. crash (on occasion I had to type in a longer search term than > FEAT_EVAL, underscores seem to matter by looking at the original > report) > > I had a quick check with GDB and the problem is on line 8556 in > fileio.c. The curwin pointer is set to NULL. It is set to NULL just > before on line 8549 due to firstwin being NULL. Haven't figured out > why this happens and have run out of time now so I thought I'd report > my findings. > > Backtrace: > > Program received signal EXC_BAD_ACCESS, Could not access memory. > Reason: KERN_PROTECTION_FAILURE at address: 0x00000000 > 0x000893cd in aucmd_restbuf (aco=0xbfffe458) at fileio.c:8556 > 8556 curbuf = curwin->w_buffer; > (gdb) bt > #0 0x000893cd in aucmd_restbuf (aco=0xbfffe458) at fileio.c:8556 > #1 0x0011cc10 in load_dummy_buffer (fname=0x502e40 > "farsi/fonts/UNIXs/far-a01.pcf.Z") at quickfix.c:3447 > #2 0x0011c390 in ex_vimgrep (eap=0xbfffef04) at quickfix.c:3146 > #3 0x0005eb9f in do_one_cmd (cmdlinep=0xbffff354, sourcing=0, > cstack=0xbffff050, fgetline=0x753b1 <getexline>, cookie=0x0) at > ex_docmd.c:2634 > #4 0x0005b8fd in do_cmdline (cmdline=0x0, getline=0x753b1 > <getexline>, cookie=0x0, flags=0) at ex_docmd.c:1103 > #5 0x000ec961 in nv_colon (cap=0xbffff478) at normal.c:5252 > #6 0x000e4d30 in normal_cmd (oap=0xbffff534, toplevel=1) at normal.c:1188 > #7 0x0009fc4f in main_loop (cmdwin=0, noexmode=0) at main.c:1261 > #8 0x0009f742 in main (argc=3, argv=0xbffff700) at main.c:1005 Hopefully this is fixed by this pending patch: *** ../vim-7.2.239/src/fileio.c 2009-07-01 17:11:40.000000000 +0200 --- src/fileio.c 2009-07-22 19:08:55.000000000 +0200 *************** *** 8420,8425 **** --- 8420,8429 ---- if (aucmd_win == NULL) win = curwin; } + if (win == NULL && aucmd_win_used) + /* Strange recursive autocommand, fall back to using the current + * window. Expect a few side effects... */ + win = curwin; aco->save_curwin = curwin; aco->save_curbuf = curbuf; *************** *** 8428,8433 **** --- 8432,8438 ---- /* There is a window for "buf" in the current tab page, make it the * curwin. This is preferred, it has the least side effects (esp. if * "buf" is curbuf). */ + aco->use_aucmd_win = FALSE; curwin = win; } else *************** *** 8436,8444 **** --- 8441,8460 ---- * effects, insert it in a the current tab page. * Anything related to a window (e.g., setting folds) may have * unexpected results. */ + aco->use_aucmd_win = TRUE; + aucmd_win_used = TRUE; aucmd_win->w_buffer = buf; ++buf->b_nwindows; win_init_empty(aucmd_win); /* set cursor and topline to safe values */ + vim_free(aucmd_win->w_localdir); + aucmd_win->w_localdir = NULL; + + /* Make sure w_localdir and globaldir are NULL to avoid a chdir() in + * win_enter_ext(). */ + aucmd_win->w_localdir = NULL; + aco->globaldir = globaldir; + globaldir = NULL; + #ifdef FEAT_WINDOWS /* Split the current window, put the aucmd_win in the upper half. *************** *** 8472,8478 **** int dummy; #endif ! if (aco->new_curwin == aucmd_win) { --curbuf->b_nwindows; #ifdef FEAT_WINDOWS --- 8488,8494 ---- int dummy; #endif ! if (aco->use_aucmd_win) { --curbuf->b_nwindows; #ifdef FEAT_WINDOWS *************** *** 8499,8504 **** --- 8515,8521 ---- /* Remove the window and frame from the tree of frames. */ (void)winframe_remove(curwin, &dummy, NULL); win_remove(curwin, NULL); + aucmd_win_used = FALSE; last_status(FALSE); /* may need to remove last status line */ restore_snapshot(SNAP_AUCMD_IDX, FALSE); (void)win_comp_pos(); /* recompute window positions */ *************** *** 8517,8522 **** --- 8534,8542 ---- #endif curbuf = curwin->w_buffer; + vim_free(globaldir); + globaldir = aco->globaldir; + /* the buffer contents may have changed */ check_cursor(); if (curwin->w_topline > curbuf->b_ml.ml_line_count) *************** *** 8541,8547 **** #endif { /* Restore the buffer which was previously edited by curwin, if ! * it was chagned, we are still the same window and the buffer is * valid. */ if (curwin == aco->new_curwin && curbuf != aco->new_curbuf --- 8561,8567 ---- #endif { /* Restore the buffer which was previously edited by curwin, if ! * it was changed, we are still the same window and the buffer is * valid. */ if (curwin == aco->new_curwin && curbuf != aco->new_curbuf *** ../vim-7.2.239/src/globals.h 2009-06-16 16:01:34.000000000 +0200 --- src/globals.h 2009-07-22 19:50:53.000000000 +0200 *************** *** 541,546 **** --- 541,547 ---- #ifdef FEAT_AUTOCMD EXTERN win_T *aucmd_win; /* window used in aucmd_prepbuf() */ + EXTERN int aucmd_win_used INIT(= FALSE); /* aucmd_win is being used */ #endif /* *** ../vim-7.2.239/src/structs.h 2009-07-09 18:24:24.000000000 +0200 --- src/structs.h 2009-07-22 18:58:35.000000000 +0200 *************** *** 2288,2296 **** --- 2288,2298 ---- { buf_T *save_curbuf; /* saved curbuf */ #ifdef FEAT_AUTOCMD + int use_aucmd_win; /* using aucmd_win */ win_T *save_curwin; /* saved curwin */ win_T *new_curwin; /* new curwin */ buf_T *new_curbuf; /* new curbuf */ + char_u *globaldir; /* saved value of globaldir */ #endif } aco_save_T; -- hundred-and-one symptoms of being an internet addict: 104. When people ask about the Presidential Election you ask "Which country?" /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ download, build and distribute -- http://www.A-A-P.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org /// --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
