Ok, I know what the problem is - this reproduces on the playground as well.
The issue is that libc::timezone
is an uninhabited type (initially I didn't even bother checking how this type is defined there):
pub enum timezone {}
Doing let tz: timezone = std::mem::uninitialized()
(or zeroed(), doesn't matter) is immediate UB; the compiler places the ud2
instruction, which is the canonical "trap" instruction for UB.
So the fix is actually what I suggested earlier, albeit I claimed it wasn't for safety :
let mut tv: timeval = ::std::mem::uninitialized();
gettimeofday(&mut tv, std::ptr::null_mut());