thisKai / rust-windows-dll

Macro for dynamically loading windows dll functions
MIT License
19 stars 6 forks source link

Panic on Option unwrap in get_proc_ptr #7

Closed vthib closed 2 years ago

vthib commented 2 years ago

Since the 0.4 update, we sometime (rarely, but happens from time to time) this panic:

panicked at 'called `Option::unwrap()` on a `None` value', /home/vthib/.cargo/registry/src/github.com-1ecc6299db9ec8
23/windows-dll-0.4.0/src/cache.rs:76:45

Reading the code, I can see a race condition which can make this happen. From what I can tell from the code:

This is racy:

One solution should be to only store the handle after the initialization of the procs once_cell in load_and_cache_lib.