diff --git a/src/bump_allocator.rs b/src/bump_allocator.rs index ed92f7d..9334fa0 100644 --- a/src/bump_allocator.rs +++ b/src/bump_allocator.rs @@ -3,7 +3,7 @@ use std::{ usize, }; -use libc::{c_void, ftruncate, mmap, syscall, SYS_memfd_secret, MAP_FAILED, MAP_SHARED, PROT_READ, PROT_WRITE}; +use libc::{c_char, c_void, ftruncate, mmap, perror, syscall, SYS_memfd_secret, MAP_FAILED, MAP_SHARED, PROT_READ, PROT_WRITE}; pub(crate) const MEMFD_INITIAL_SIZE: usize = 1024 * 1024; const MMAP_SIZE: usize = 1024 * 1024; @@ -27,6 +27,9 @@ impl BumpAllocator { assert!(MMAP_SIZE >= MEMFD_INITIAL_SIZE); let data_fd = syscall(SYS_memfd_secret, 0) as i32; + if data_fd <= 0 { + perror("memfd secret\x00".as_ptr() as *const c_char); + } assert!(data_fd > 0);