{"record":{"id":"f1fc8967446643c2","repo":"oven-sh/bun","slug":"rtlgenrandom-failed","errorCode":null,"errorMessage":"RtlGenRandom failed","messagePattern":"RtlGenRandom failed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/bun_core/util.rs","lineNumber":2754,"sourceCode":"            // SAFETY: chunk is a valid writable slice ≤ 256 bytes.\n            let rc = unsafe { libc::getentropy(chunk.as_mut_ptr().cast(), chunk.len()) };\n            if rc != 0 {\n                panic!(\"getentropy failed\");\n            }\n        }\n    }\n    #[cfg(windows)]\n    {\n        unsafe extern \"system\" {\n            // advapi32!SystemFunction036 a.k.a. RtlGenRandom — what BoringSSL uses on Windows.\n            #[link_name = \"SystemFunction036\"]\n            fn RtlGenRandom(buf: *mut u8, len: u32) -> u8;\n        }\n        for chunk in bytes.chunks_mut(u32::MAX as usize) {\n            // SAFETY: chunk fits in u32; RtlGenRandom writes exactly that many bytes.\n            let ok = unsafe { RtlGenRandom(chunk.as_mut_ptr(), chunk.len() as u32) };\n            if ok == 0 {\n                panic!(\"RtlGenRandom failed\");\n            }\n        }\n    }\n}\n\n// ── self_exe_path ─────────────────────────────────────────────────────────\n// Memoized into a process-lifetime\n// static buffer; thread-safe via `Once`. Returns a `&'static ZStr`.\npub fn self_exe_path() -> crate::CrateResult<&'static ZStr> {\n    static CELL: Once<crate::CrateResult<ZBox>> = Once::new();\n    let r = CELL.get_or_init(|| {\n        let path = std::env::current_exe().map_err(|_| crate::CrateError::Unexpected)?;\n        // Symlink resolution: Rust's\n        // `current_exe()` already resolves on Linux (`readlink /proc/self/exe`),\n        // but on Darwin it returns the raw `_NSGetExecutablePath` result and on\n        // Windows it returns the raw `GetModuleFileNameW` result — neither\n        // realpaths, so a symlinked argv0 (Darwin) or an un-normalized\n        // `C:\\a\\.\\b\\bun.exe` load path (Windows) leaks through to","sourceCodeStart":2736,"sourceCodeEnd":2772,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/src/bun_core/util.rs#L2736-L2772","documentation":"Error \"RtlGenRandom failed\" thrown in oven-sh/bun.","triggerScenarios":"Thrown at src/bun_core/util.rs:2754 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}