nvim-oxi: Crash when loading the example plugin on Windows
Hello,
I am using the crate setup example from the repo and Neovim crashes when loading the plugin DLL file by requiring the module. I am copying the DLL directly to NeoVim’s bin
directory.
The nvim process crashes with virtually no way to debug it.
I tried the latest git version of nvim-oxi
.
I am on Windows, I added the /force:UNRESOLVED
flags to my cargo config:
[target.x86_64-pc-windows-msvc]
rustflags = [
"-C", "link-arg=/FORCE:UNRESOLVED",
]
[target.aarch64-pc-windows-msvc]
rustflags = [
"-C", "link-arg=/FORCE:UNRESOLVED",
]
About this issue
- Original URL
- State: closed
- Created 6 months ago
- Comments: 29 (12 by maintainers)
Not necessarily, the
.lib
files only contain function definitions to interface with the symbols insidenvim.exe
at link time. After thorough testing, I can confirm that bothnvim.lib
andlua51.lib
work interchangeably in NeoVim nightly and 0.9, everything works as long as you are compiling with the correct version feature.If storing the
.lib
files is an issue, I can write a script that generates anvim.lib
usingdumpbin.exe
. However, the user will need NeoVim installed to build the crate.I can use https://github.com/SecSamDev/dumpbin inside
build.rs
@theofabilous could you open a PR? Imo there’s no point in blocking this over whose PR gets merged.
@theofabilous Credits where credits due.
I used Rust’s built-in
#[link]
attribute above eachextern C
. When setting thelink-type
toraw-dylib
,rustc
automatically generates an import library. This solved the issue without providing our import libraries. Most importantly, it now relies on the NeoVim executable, making the fix compatible with all versions.I added a mechanism to locate the NeoVim installation directory, it will look for NeoVim in the
PATH
and then in an environment variableNVIM_DIR
.These changes are reflected in my PR.
You are right, any call to
nvim
API segfaults with an access violation error. I tried debugging the nvim process in VS.It seems likenvim.exe
linkslibnvim
statically as well. So I can’t really access the nvim symbols, can I?dumpbin.exe
indeed shows thenvim_*
symbols as exported.I’m encountering this as well. Crashes immediately upon requiring the module. I’m running on NVIM v0.10.0-dev-2135+g98a4ed0a1 and current git main for the nvim-oxi dependency