simnalamburt / vim-mundo

:christmas_tree: Vim undo tree visualizer
https://simnalamburt.github.io/vim-mundo
GNU General Public License v2.0
791 stars 28 forks source link

vim-mundo crash #97

Closed cridemichel closed 3 years ago

cridemichel commented 4 years ago

Hi, first of all I have to say that I found this plugin very useful and I appreciate a lot what you are doing! I am having the following odd behavior: if you open vim-mundo and you either press 'r' or 'd' both mundo windows close suddenly. To reproduce the issue I prepared the following minimal .vimrc file:

set nocompatible
let &runtimepath  = '~/.vim/plugged/vim-mundo,' . &runtimepath
filetype plugin indent on
syntax enable
set undolevels=1000 
set undofile
set undodir=~/.vim/undo

thank you for you help, best Cristiano

simnalamburt commented 4 years ago

Hi @cridemichel! Thanks you for reporting the bug in detail.

I copied your vimrc and invoked Mundo and actually it worked fine in my environment. I think something else in your development environment have caused this issue. Can you share more information?

image

My env:

$ uname -a
Linux mycomputer 4.4.0-18362-Microsoft #476-Microsoft Fri Nov 01 16:53:00 PST 2019 x86_64 GNU/Linux
$ vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Jun 15 2019 16:41:15)
Included patches: 1-875, 878, 884, 948, 1046, 1365-1368, 1382, 1401
Modified by team+vim@tracker.debian.org
Compiled by team+vim@tracker.debian.org
Huge version without GUI.  Features included (+) or not (-):
+acl               +extra_search      +mouse_netterm     +tag_old_static
+arabic            +farsi             +mouse_sgr         -tag_any_white
+autocmd           +file_in_path      -mouse_sysmouse    +tcl
+autochdir         +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
-balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
-browse            +fork()            -mzscheme          +textobjects
++builtin_terms    +gettext           +netbeans_intg     +textprop
+byte_offset       -hangul_input      +num64             +timers
+channel           +iconv             +packages          +title
+cindent           +insert_expand     +path_extra        -toolbar
-clientserver      +job               +perl              +user_commands
-clipboard         +jumplist          +persistent_undo   +vartabs
+cmdline_compl     +keymap            +postscript        +vertsplit
+cmdline_hist      +lambda            +printer           +virtualedit
+cmdline_info      +langmap           +profile           +visual
+comments          +libcall           -python            +visualextra
+conceal           +linebreak         +python3           +viminfo
+cryptv            +lispindent        +quickfix          +vreplace
+cscope            +listcmds          +reltime           +wildignore
+cursorbind        +localmap          +rightleft         +wildmenu
+cursorshape       +lua               +ruby              +windows
+dialog_con        +menu              +scrollbind        +writebackup
+diff              +mksession         +signs             -X11
+digraphs          +modify_fname      +smartindent       -xfontset
-dnd               +mouse             +startuptime       -xim
-ebcdic            -mouseshape        +statusline        -xpm
+emacs_tags        +mouse_dec         -sun_workshop      -xsmp
+eval              +mouse_gpm         +syntax            -xterm_clipboard
+ex_extra          -mouse_jsbterm     +tag_binary        -xterm_save
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-4Pursk/vim-8.1.0875=. -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L. -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E  -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.28/CORE -lperl -ldl -lm -lpthread -lcrypt  -L/usr/lib/python3.7/config-3.7m-x86_64-linux-gnu -lpython3.7m -lcrypt -lpthread -ldl -lutil -lm -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lm -lruby-2.5 -lpthread -lgmp -ldl -lcrypt -lm
$ which python3
/usr/bin/python3
$ python3 --version
Python 3.7.3

Thanks!

simnalamburt commented 4 years ago

And if there's any error message, I'd love to see it :)

cridemichel commented 4 years ago

Hi, thank you for the prompt reply. Unfortunately I am not getting any error. My env is the following:

> uname -a
Darwin MacBook-Pro-5.local 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar  4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64

and

> vim --version
Darwin MacBook-Pro-5.local 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar  4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64
❯ vim --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compilato May  6 2020 06:17:56)
Versione macOS
Patch incluse: 1-700
Compilato da Homebrew
Versione gigante senza GUI.  FunzionalitΓ  incluse (+) o escluse (-):
+acl               -farsi             +mouse_sgr         +tag_binary
+arabic            +file_in_path      -mouse_sysmouse    -tag_old_static
+autocmd           +find_in_path      +mouse_urxvt       -tag_any_white
+autochdir         +float             +mouse_xterm       -tcl
-autoservername    +folding           +multi_byte        +termguicolors
-balloon_eval      -footer            +multi_lang        +terminal
+balloon_eval_term +fork()            -mzscheme          +terminfo
-browse            +gettext           +netbeans_intg     +termresponse
++builtin_terms    -hangul_input      +num64             +textobjects
+byte_offset       +iconv             +packages          +textprop
+channel           +insert_expand     +path_extra        +timers
+cindent           +ipv6              +perl              +title
-clientserver      +job               +persistent_undo   -toolbar
+clipboard         +jumplist          +popupwin          +user_commands
+cmdline_compl     +keymap            +postscript        +vartabs
+cmdline_hist      +lambda            +printer           +vertsplit
+cmdline_info      +langmap           +profile           +virtualedit
+comments          +libcall           -python            +visual
+conceal           +linebreak         +python3           +visualextra
+cryptv            +lispindent        +quickfix          +viminfo
+cscope            +listcmds          +reltime           +vreplace
+cursorbind        +localmap          +rightleft         +wildignore
+cursorshape       +lua               +ruby              +wildmenu
+dialog_con        +menu              +scrollbind        +windows
+diff              +mksession         +signs             +writebackup
+digraphs          +modify_fname      +smartindent       -X11
-dnd               +mouse             -sound             -xfontset
-ebcdic            -mouseshape        +spell             -xim
+emacs_tags        +mouse_dec         +startuptime       -xpm
+eval              -mouse_gpm         +statusline        -xsmp
+ex_extra          -mouse_jsbterm     -sun_workshop      -xterm_clipboard
+extra_search      +mouse_netterm     +syntax            -xterm_save
   file vimrc di sistema: "$VIM/vimrc"
       file vimrc utente: "$HOME/.vimrc"
    II file vimrc utente: "~/.vim/vimrc"
        file exrc utente: "$HOME/.exrc"
        file dei default: "$VIMRUNTIME/defaults.vim"
         $VIM di riserva: "/usr/local/share/vim"
Compilazione: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Link: clang   -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -lintl -framework AppKit  -L/usr/local/opt/lua/lib -llua5.3 -mmacosx-version-min=10.15 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.30.2_1/lib/perl5/5.30.2/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc  -L/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/config-3.8-darwin -lpython3.8 -framework CoreFoundation  -lruby.2.7

and

> python3 --version
Python 3.7.7

best C.

cridemichel commented 4 years ago

Hi, is it enough the information which I provided or you need something else? best C.

simnalamburt commented 4 years ago

Hi @cridemichel! It is a period of final exams at my university, so I am very busy these days. 😒 I'll try to reproduce it when I have some free time. Thanks!

cridemichel commented 4 years ago

no problem, thank you for the reply and good luck for your exams!

Cristiano De Michele cristiano.demichele@gmail.com

Il giorno 26 mag 2020, alle ore 11:29, Hyeon Kim (κΉ€μ§€ν˜„) notifications@github.com ha scritto:

Hi @cridemichel https://github.com/cridemichel! It is a period of final exams at my university, so I am very busy these days. 😒 I'll try to reproduce it when I have some free time. Thanks!

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/simnalamburt/vim-mundo/issues/97#issuecomment-633915670, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADU4YGRNH4ECPQGBHDTLQ3TRTODWHANCNFSM4M4WWJ3Q.

cridemichel commented 3 years ago

Dear Developer, I hope your exams went well :-), any news on this? best C.

simnalamburt commented 3 years ago

Sorry for the late update πŸ˜… I finished the spring semester well, and now I am dealing with the fall semester.

Unfortunately I'm still failing to reproduce this issue.. so sorry maybe I need to prepare some exact same environment 😒

cridemichel commented 3 years ago

Dear Hyeon, what I discovered is that the issue is related to the python script mundo.py. Something bad happened when executing the following function:

def MundoRenderPatchdiff():# {{{
    """ Call MundoRenderChangePreview and display a vert diffpatch with the
    current file. """
    if MundoRenderChangePreview():
        # if there are no lines, do nothing (show a warning).
        util._goto_window_for_buffer('__Mundo_Preview__')
        if vim.current.buffer[:] == ['']:
            # restore the cursor position before exiting.
            util._goto_window_for_buffer('__Mundo__')
            vim.command('unsilent echo "No difference between current file and undo number!"')
            return False

        # quit out of mundo main screen
        util._goto_window_for_buffer('__Mundo__')
        vim.command('quit')

        # save the __Mundo_Preview__ buffer to a temp file.
        util._goto_window_for_buffer('__Mundo_Preview__')
        (handle,filename) = tempfile.mkstemp()
        vim.command('silent! w %s' % (filename))
        # exit the __Mundo_Preview__ window
        vim.command('bdelete')
        # diff the temp file
        vim.command('silent! keepalt vert diffpatch %s' % (filename)) #<----------
        vim.command('set buftype=nofile bufhidden=delete')
        return True
    return False
# }}}

in particular the line marked with an arrow seems to be the culprit. Is it possible that the temporary file called filename is not properly created? When I will have time, I will try to investigate more the issue,

best Cristiano

Cristiano De Michele cristiano.demichele@gmail.com

Il giorno 8 nov 2020, alle ore 14:20, Hyeon Kim (κΉ€μ§€ν˜„) notifications@github.com ha scritto:

Sorry for the late update πŸ˜… I finished the spring semester well, and now I am dealing with the fall semester.

Unfortunately I'm still failing to reproduce this issue.. so sorry maybe I need to prepare some exact same environment 😒

β€” You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/simnalamburt/vim-mundo/issues/97#issuecomment-723576480, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADU4YGQ33UJ7LA2O3IGH4TTSO2LLPANCNFSM4M4WWJ3Q.

cridemichel commented 3 years ago

Dear Hyeon, I think I have finally fixed it. The problem was the following instruction:

vim.command('silent! w %s' % (filename))

inside the function

MundoRenderPatchdiff() 

in the file mundo.py. Indeed, the file called filename in my existed already and it was not able to overwrite it. An easy workaround is to replace this line with:

vim.command('silent! w! %s' % (filename))

where a β€˜!’ is added after w, thus forcing the writing of the file filename,

I have just created a corresponding pull request,

best C.

Cristiano De Michele cristiano.demichele@gmail.com

Il giorno 8 nov 2020, alle ore 14:20, Hyeon Kim (κΉ€μ§€ν˜„) notifications@github.com ha scritto:

Sorry for the late update πŸ˜… I finished the spring semester well, and now I am dealing with the fall semester.

Unfortunately I'm still failing to reproduce this issue.. so sorry maybe I need to prepare some exact same environment 😒

β€” You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/simnalamburt/vim-mundo/issues/97#issuecomment-723576480, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADU4YGQ33UJ7LA2O3IGH4TTSO2LLPANCNFSM4M4WWJ3Q.

simnalamburt commented 3 years ago

Nice catch!! Thanks for your contribution βœ¨πŸ‘πŸ’―πŸ‘βœ¨

Closed by https://github.com/simnalamburt/vim-mundo/pull/104