oven-sh/bun · error
RtlGenRandom failed
Error message
RtlGenRandom failed
What it means
Error "RtlGenRandom failed" thrown in oven-sh/bun.
Source
Thrown at src/bun_core/util.rs:2754
// SAFETY: chunk is a valid writable slice ≤ 256 bytes.
let rc = unsafe { libc::getentropy(chunk.as_mut_ptr().cast(), chunk.len()) };
if rc != 0 {
panic!("getentropy failed");
}
}
}
#[cfg(windows)]
{
unsafe extern "system" {
// advapi32!SystemFunction036 a.k.a. RtlGenRandom — what BoringSSL uses on Windows.
#[link_name = "SystemFunction036"]
fn RtlGenRandom(buf: *mut u8, len: u32) -> u8;
}
for chunk in bytes.chunks_mut(u32::MAX as usize) {
// SAFETY: chunk fits in u32; RtlGenRandom writes exactly that many bytes.
let ok = unsafe { RtlGenRandom(chunk.as_mut_ptr(), chunk.len() as u32) };
if ok == 0 {
panic!("RtlGenRandom failed");
}
}
}
}
// ── self_exe_path ─────────────────────────────────────────────────────────
// Memoized into a process-lifetime
// static buffer; thread-safe via `Once`. Returns a `&'static ZStr`.
pub fn self_exe_path() -> crate::CrateResult<&'static ZStr> {
static CELL: Once<crate::CrateResult<ZBox>> = Once::new();
let r = CELL.get_or_init(|| {
let path = std::env::current_exe().map_err(|_| crate::CrateError::Unexpected)?;
// Symlink resolution: Rust's
// `current_exe()` already resolves on Linux (`readlink /proc/self/exe`),
// but on Darwin it returns the raw `_NSGetExecutablePath` result and on
// Windows it returns the raw `GetModuleFileNameW` result — neither
// realpaths, so a symlinked argv0 (Darwin) or an un-normalized
// `C:\a\.\b\bun.exe` load path (Windows) leaks through toView on GitHub (pinned to 8c5296ac45)
When it happens
Trigger: Thrown at src/bun_core/util.rs:2754 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/f1fc8967446643c2.
Report an issue: GitHub.