Re: saveas -> loads ft plugin -> changes dir -> wrong filename problem
On Tue, Nov 16, 2010 at 2:35 PM, Kevin Klement wrote: > Thanks for looking into this. > > I've removed all manually installed filetype plugins (--I didn't go so > far as to change or remove the default ones--), and created a single > one inside: > > ~/.vim/ftplugin/ > > named "html.vim" consisting of a single line: > > setlocal autochdir > > (it works with "set autochdir" too, and seems to work with variants of > lcd ...) too. > > This line by itself seems to create the problem. In fact, I've never > used a third-party html plugin, and the only other things I've ever > had in my html.vim are relatively benign keymaps. > > In that case, the following seems to generate the problem most of the time. > > ~/tmp $ vim -u NONE -N > :filetype plugin on > :saveas ~/tmp/junk.html That made it pretty easy to reproduce. As the attached valgrind log shows, the src variable in home_replace is pointing to free'd memory. This appears to be the same memory being used by curbuf->b_sfname before running the filetype autocmd. I've attached a patch which appears to fix it, although I'm wary of the strcpy since I'm not sure we can guarantee there's enough space for the copy. -- James GPG Key: 1024D/61326D40 2003-09-02 James Vega -- 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 vim.out Description: Binary data saveas.diff Description: Binary data
Re: saveas -> loads ft plugin -> changes dir -> wrong filename problem
Thanks for looking into this. I've removed all manually installed filetype plugins (--I didn't go so far as to change or remove the default ones--), and created a single one inside: ~/.vim/ftplugin/ named "html.vim" consisting of a single line: setlocal autochdir (it works with "set autochdir" too, and seems to work with variants of lcd ...) too. This line by itself seems to create the problem. In fact, I've never used a third-party html plugin, and the only other things I've ever had in my html.vim are relatively benign keymaps. In that case, the following seems to generate the problem most of the time. ~/tmp $ vim -u NONE -N :filetype plugin on :saveas ~/tmp/junk.html If the filetype plugin is a one-liner, such as above, the bad filename it uses is usually a bunch of control characters rather than some additional lines from the plugin. Some observations: 1. I do not always observe the same behavior, even when going through exactly the same steps. This has made it hard to troubleshoot. (The erroneous filename it uses, for example, seems to be different every time.) 2. Occasionally I do not get the bug just going through the motions above, though I do more often than not. When I don't get it, usually I can repeat the same steps and I'll get it the second, or third, time, e.g.: ~/tmp $ vim -u NONE -N :filetype plugin on :saveas ~/tmp/scratch.html :q ~/tmp $ vim -u NONE -N :filetype plugin on :saveas! ~/tmp/scratch.html :q 2. At the moment, I can only produce the bug using :saveas(!), not :w or :write. (I have some memory of getting it with :w in the past, but cannot duplicate that right now.) 3. I seem to get the bug more regularly if (1) the filename used in the :saveas step uses ~/ for the home folder, (2) the folder in question is actually where I launched vim from (yes, I know this makes it redundant to use "~/" with :saveas, but in actual use scenarios I seldom remember this). However, I have gotten the bug saving just to "/tmp/". These observations may be coincidences, however. At least one slash needs to be in the filename, however. 4. Adding :set nocp into that mix seems not to matter. 5. For *.tex files, as in my previous report, I need to also use: let g:tex_flavor = "latex" to get the same behavior with a tex.vim plugin, but I think that's because it loads plaintex.vim otherwise. I wish I could provide more info, especially because the behavior is very unpredictable, but perhaps that'll be enough to pinpoint a problem. -Kevin On Tue, Nov 16, 2010 at 7:07 AM, Bram Moolenaar wrote: > > Klement wrote: > >> I'm here to report what looks like a bug to me. Hopefully I'm not >> wasting your time. >> >> Here are the conditions. >> >> 1. Edit a blank file with no ft set (and hence no filetype plugins >> loaded). >> >> 2. Attempt to save the file with an extension which causes a filetype >> plugin to be loaded. (It seems to help if the filename chosen has >> slashes in it for directories.) >> >> 3. The plugin in question must be one that changes the active >> directory (through a command like `lcd %:p:r` or `set autochdir`). >> >> 4. Then rather than saving the file with the filename specified in >> step 2, it saves the file under a seemingly random name, often using >> what appears to be a line of code from the plugin as if it were the >> filename (though not the same line as mentioned in line 3). >> >> Anyway, I've recorded an animated .gif of the apparent bug in action, >> which you can view here: >> >> http://people.umass.edu/phil592w-klement/vimbug.gif >> >> You can see the file is being saved with a very strange filename, and >> not all the one specified. >> >> I'm using 7.3 on Arch Linux (x86_64). > > I can't reproduce it. It does sound like a real bug, probably using > NameBuff or IObuff in an unexpected way. > > Please find out the minimal setup to reproduce this, starting with "vim > -u NONE". > > -- > A law to reduce crime states: "It is mandatory for a motorist with criminal > intentions to stop at the city limits and telephone the chief of police as he > is entering the town. > [real standing law in Washington, United States of America] > > /// Bram Moolenaar -- b...@moolenaar.net -- 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
Re: saveas -> loads ft plugin -> changes dir -> wrong filename problem
Klement wrote: > I'm here to report what looks like a bug to me. Hopefully I'm not > wasting your time. > > Here are the conditions. > > 1. Edit a blank file with no ft set (and hence no filetype plugins > loaded). > > 2. Attempt to save the file with an extension which causes a filetype > plugin to be loaded. (It seems to help if the filename chosen has > slashes in it for directories.) > > 3. The plugin in question must be one that changes the active > directory (through a command like `lcd %:p:r` or `set autochdir`). > > 4. Then rather than saving the file with the filename specified in > step 2, it saves the file under a seemingly random name, often using > what appears to be a line of code from the plugin as if it were the > filename (though not the same line as mentioned in line 3). > > Anyway, I've recorded an animated .gif of the apparent bug in action, > which you can view here: > > http://people.umass.edu/phil592w-klement/vimbug.gif > > You can see the file is being saved with a very strange filename, and > not all the one specified. > > I'm using 7.3 on Arch Linux (x86_64). I can't reproduce it. It does sound like a real bug, probably using NameBuff or IObuff in an unexpected way. Please find out the minimal setup to reproduce this, starting with "vim -u NONE". -- A law to reduce crime states: "It is mandatory for a motorist with criminal intentions to stop at the city limits and telephone the chief of police as he is entering the town. [real standing law in Washington, United States of America] /// Bram Moolenaar -- b...@moolenaar.net -- 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
Re: saveas -> loads ft plugin -> changes dir -> wrong filename problem
frabjous wrote: Hi all, I'm here to report what looks like a bug to me. Hopefully I'm not wasting your time. Here are the conditions. 1. Edit a blank file with no ft set (and hence no filetype plugins loaded). 2. Attempt to save the file with an extension which causes a filetype plugin to be loaded. (It seems to help if the filename chosen has slashes in it for directories.) 3. The plugin in question must be one that changes the active directory (through a command like `lcd %:p:r` or `set autochdir`). 4. Then rather than saving the file with the filename specified in step 2, it saves the file under a seemingly random name, often using what appears to be a line of code from the plugin as if it were the filename (though not the same line as mentioned in line 3). Anyway, I've recorded an animated .gif of the apparent bug in action, which you can view here: http://people.umass.edu/phil592w-klement/vimbug.gif You can see the file is being saved with a very strange filename, and not all the one specified. I'm using 7.3 on Arch Linux (x86_64). I tried creating an empty file via :enew, saving it to /tmp/junk.tex, and that went as one would expect it should. I think that you need to track down which ftplugin is giving you problems. Given that you have what appears to be a line of text from it, perhaps you could do a search for that text and locate where that text came from -- perhaps that ftplugin is the one causing problems. Disable it (mv whatever.vim whatever.vvim) and try it out. If it the process still results in problems, then try disabling more ftplugins until you find your culprit. Alternatively, t may well be an unfortunate interaction with settings you may have, so try using vim -u NONE -N :set nocp :filetype plugin on :w /tmp/junk.tex :q and see if that creates your unwanted filename. Regards, Chip Campbell -- 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
saveas -> loads ft plugin -> changes dir -> wrong filename problem
Hi all, I'm here to report what looks like a bug to me. Hopefully I'm not wasting your time. Here are the conditions. 1. Edit a blank file with no ft set (and hence no filetype plugins loaded). 2. Attempt to save the file with an extension which causes a filetype plugin to be loaded. (It seems to help if the filename chosen has slashes in it for directories.) 3. The plugin in question must be one that changes the active directory (through a command like `lcd %:p:r` or `set autochdir`). 4. Then rather than saving the file with the filename specified in step 2, it saves the file under a seemingly random name, often using what appears to be a line of code from the plugin as if it were the filename (though not the same line as mentioned in line 3). Anyway, I've recorded an animated .gif of the apparent bug in action, which you can view here: http://people.umass.edu/phil592w-klement/vimbug.gif You can see the file is being saved with a very strange filename, and not all the one specified. I'm using 7.3 on Arch Linux (x86_64). Thanks! -- 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