mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-20 03:32:44 +08:00
Add note about possible safety issue with GLOBAL_NODE
This commit is contained in:
parent
66618d64cb
commit
ec1bf60941
5
src/env/environment_impl.rs
vendored
5
src/env/environment_impl.rs
vendored
|
@ -273,6 +273,10 @@ impl Iterator for EnvNodeIter {
|
|||
}
|
||||
|
||||
lazy_static! {
|
||||
/// XXX: Possible safety issue here as EnvNodeRef is not Send/Sync and shouldn't
|
||||
/// be placed in a static context without some sort of Send/Sync wrapper.
|
||||
/// lazy_static papers over this but it triggers rust lints if you use
|
||||
/// once_cell::sync::Lazy or std::sync::OnceLock instead.
|
||||
static ref GLOBAL_NODE: EnvNodeRef = EnvNodeRef::new(false, None);
|
||||
}
|
||||
|
||||
|
@ -699,6 +703,7 @@ pub struct EnvStackImpl {
|
|||
impl EnvStackImpl {
|
||||
/// Return a new impl representing global variables, with a single local scope.
|
||||
pub fn new() -> EnvMutex<EnvStackImpl> {
|
||||
// XXX: Safety issue: We are accessing GLOBAL_NODE without having the global mutex locked!
|
||||
let globals = GLOBAL_NODE.clone();
|
||||
let locals = EnvNodeRef::new(false, None);
|
||||
let base = EnvScopedImpl::new(locals, globals);
|
||||
|
|
Loading…
Reference in New Issue
Block a user