mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 11:06:54 -04:00
fix(install): unlink files before copy on unix to prevent crashes (#8517)
uv_fs_copyfile will truncate the target first, which can result in hard-to-debug crashes if the shared object is currently in use. instead, unlink the target first, so that the operation doesn't modify any in-use files. the disk space from the old parsers won't be reclaimed until any processes using them relinquish their open file handles.
This commit is contained in:
parent
ecdae44bae
commit
3edb01f912
1 changed files with 2 additions and 0 deletions
|
|
@ -302,6 +302,8 @@ local function do_install(logger, compile_location, target_location)
|
|||
local tempfile = target_location .. tostring(uv.hrtime())
|
||||
uv_rename(target_location, tempfile) -- parser may be in use: rename...
|
||||
uv_unlink(tempfile) -- ...and mark for garbage collection
|
||||
else
|
||||
uv_unlink(target_location) -- don't disturb existing memory-mapped content
|
||||
end
|
||||
|
||||
local err = uv_copyfile(compile_location, target_location)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue