#[non_exhaustive]pub enum LockError {
Map {
bytes: usize,
source: Error,
},
Guard {
source: Error,
},
Refused {
bytes: usize,
limit: Option<u64>,
source: Error,
},
Dump {
source: Error,
},
Unavailable,
Forked,
Untracked {
source: Error,
},
Alignment {
align: usize,
page: usize,
},
}Expand description
Why a Locked value could not be created, or why its memory is not
locked.
Refused, Dump,
Untracked, Unavailable
and Forked describe a degraded value that
exists: under LockPolicy::BestEffort the first four are reported by
Locked::lock_error from construction on, and Forked from the moment
a forked child looks. Locked::require_locked turns any of them into
an error and drops the value. The other variants mean no value was
created.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Map
The operating system would not map the region at all.
Fields
Guard
The region was mapped but a guard page could not be protected.
Refused
mlock refused the interior, almost always because it would exceed
RLIMIT_MEMLOCK (64 KiB by default on many Linux hosts). Every
value costs at least one page of that limit whatever its size, so
the default holds sixteen 4 KiB-page values, or a single one where
pages are 64 KiB. Raise the limit with ulimit -l, LimitMEMLOCK=
in a systemd unit, or the container runtime’s ulimit setting.
Fields
Dump
The region is locked but could not be excluded from core dumps
(madvise(MADV_DONTDUMP) on Linux or Android was refused, which a
seccomp filter can do). The bytes would appear in a core dump.
This platform or build has no memory locking: non-Unix targets, Miri (which maps the region but cannot lock it) and Kani. The value is wiped on drop as usual.
Forked
The value was created in another process. Memory locks are not
inherited across fork, so in the child the region is unlocked
until Locked::relock is called there.
Untracked
This process cannot tell its values when they cross a fork: the
atfork handler that counts forks could not be registered (only want
of memory makes pthread_atfork fail). A forked child would then
inherit a lock it does not have with nothing to say so, so the
value is treated as unlocked here.
Alignment
T needs an alignment larger than a page, which the region cannot
provide.
Trait Implementations§
Source§impl Error for LockError
impl Error for LockError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()