You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Creating an instance of Clang involves calling clang-sys::load() which dynamically loads the clang library for the currently executing thread.
With Clang: Send (which is implemented automatically due to the auto-trait rules) the abstraction leaks when you do something like:
let clang = Clang::new();
std::thread::spawn(|| {/* use clang here */});
When code is written this way, clang attempts to directly access functions from libclang without checking whether the library is loaded and fail at the assert here.
Ultimately I think using thread-local storage here is really an instance of superfluous complexity and the library would be way better off with plain global shared variable with an atomic and a std::sync::Once or a lazy_static.
The text was updated successfully, but these errors were encountered:
Creating an instance of
Clang
involves callingclang-sys::load()
which dynamically loads the clang library for the currently executing thread.With
Clang: Send
(which is implemented automatically due to the auto-trait rules) the abstraction leaks when you do something like:When code is written this way,
clang
attempts to directly access functions fromlibclang
without checking whether the library is loaded and fail at the assert here.This bug occurred in actual code here https://github.com/twistedfall/opencv-rust/blob/master/build.rs#L99-L116
Ultimately I think using thread-local storage here is really an instance of superfluous complexity and the library would be way better off with plain global shared variable with an atomic and a
std::sync::Once
or alazy_static
.The text was updated successfully, but these errors were encountered: