{"record":{"id":"9b5e8dbb9c15d2c2","repo":"gfx-rs/wgpu","slug":"failed-to-open-lock-observation-file-does-the-dir","errorCode":null,"errorMessage":"Failed to open lock observation file (does the dir exist?)","messagePattern":"Failed to open lock observation file \\(does the dir exist\\?\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"wgpu-core/src/lock/observing.rs","lineNumber":262,"sourceCode":"/// Check and record the acquisition of a lock with `new_rank`.\n///\n/// Log the acquisition of a lock with `new_rank`, and\n/// update the per-thread state accordingly.\n///\n/// Return the `Option<HeldLock>` state that must be restored when this lock is\n/// released.\nfn acquire(new_rank: LockRank, location: &'static Location<'static>) -> Option<HeldLock> {\n    LOCK_STATE.with_borrow_mut(|state| match *state {\n        ThreadState::Disabled => None,\n        ThreadState::Initial => {\n            let Ok(dir) = std::env::var(\"WGPU_CORE_LOCK_OBSERVE_DIR\") else {\n                *state = ThreadState::Disabled;\n                return None;\n            };\n\n            // Create the observation log file.\n            let mut log = ObservationLog::create(dir)\n                .expect(\"Failed to open lock observation file (does the dir exist?)\");\n\n            // Log the full set of lock ranks, so that the analysis can even see\n            // locks that are only acquired in isolation.\n            for rank in LockRankSet::all().iter() {\n                log.write_rank(rank);\n            }\n\n            // Update our state to reflect that we are logging acquisitions, and\n            // that we have acquired this lock.\n            *state = ThreadState::Enabled {\n                held_lock: Some(HeldLock {\n                    rank: new_rank,\n                    location,\n                }),\n                log,\n            };\n\n            // Since this is the first acquisition on this thread, we know that","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/gfx-rs/wgpu/blob/3e11ff59bf3f9795d285ecc045014089640d7248/wgpu-core/src/lock/observing.rs#L244-L280","documentation":"Panic in the lock-observation machinery's acquire: opening the log file under WGPU_CORE_LOCK_OBSERVE_DIR failed, typically because the directory does not exist or is not writable. The faulty input is the environment-provided observation directory.","triggerScenarios":"Thrown at wgpu-core/src/lock/observing.rs:262 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Create the directory pointed to by WGPU_CORE_LOCK_OBSERVE_DIR before starting the program","Unset the variable if lock observation is not intended"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3e11ff59bf3f9795d285ecc045014089640d7248","analyzedAt":"2026-09-03T01:43:21.459Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}