Skip to content

Instantly share code, notes, and snippets.

@thinca
Last active March 18, 2019 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thinca/36897fa4e0df40aaf3bd7c35ff59091b to your computer and use it in GitHub Desktop.
Save thinca/36897fa4e0df40aaf3bd7c35ff59091b to your computer and use it in GitHub Desktop.
テキストプロパティで落ちるやつ
diff --git a/src/textprop.c b/src/textprop.c
index 674faebe2..00436f51a 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -629,7 +629,7 @@ f_prop_remove(typval_T *argvars, typval_T *rettv)
mch_memmove(newptr, buf->b_ml.ml_line_ptr,
buf->b_ml.ml_line_len);
buf->b_ml.ml_line_ptr = newptr;
- curbuf->b_ml.ml_flags |= ML_LINE_DIRTY;
+ buf->b_ml.ml_flags |= ML_LINE_DIRTY;
}
taillen = buf->b_ml.ml_line_len - len
func s:test()
new
let bufnr = bufnr('')
call prop_type_add('one', {})
call prop_type_add('two', {})
call setline(1, 'one two three')
call setline(2, 'one two three')
wincmd w
call prop_add(1, 5, {'length': 3, 'id': 12, 'type': 'two', 'bufnr': bufnr})
call prop_add(2, 1, {'length': 3, 'id': 11, 'type': 'one', 'bufnr': bufnr})
call prop_remove({'id': 12, 'bufnr': bufnr}, 1)
close " SEGV
endfunc
call s:test()
qa!
@thinca
Copy link
Author

thinca commented Mar 18, 2019

実行方法

vim -u NONE -i NONE -N -S test_textprop.vim

new で作ったバッファテキストを設定し、最初のバッファに戻ってからテキストプロパティを設定していっていき、最後に現在のバッファ、テキストプロパティを設定していないバッファを閉じるとクラッシュする。
f_prop_remove の実装を眺めると1箇所だけ curbuf を触っている箇所があったのでここを buf に直したところクラッシュしなくなった。
ただし memline の構造を把握できておらず、修正前が明らかに問題なのはなんとなくわかるが厳密にどう問題かは理解できていない 😇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment