From 48d7f8df3ec424d7b5770292a5d694dc4812425c Mon Sep 17 00:00:00 2001 From: He Sun Date: Mon, 27 Apr 2020 10:07:54 +0800 Subject: [PATCH] Fix the invalid epoll_event pointer introduced by compilation optimization That pointer does not point to the libc::epoll_event after release build. Explicitly declaring the libc::epoll_event avoids the invalidation. --- src/libos/src/net/io_multiplexing/epoll.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/libos/src/net/io_multiplexing/epoll.rs b/src/libos/src/net/io_multiplexing/epoll.rs index 15d3145f..b035bc9b 100644 --- a/src/libos/src/net/io_multiplexing/epoll.rs +++ b/src/libos/src/net/io_multiplexing/epoll.rs @@ -108,12 +108,11 @@ impl EpollFile { // we don't have to worry about the potential deadlock caused by // locking two files (say, fd and epfd) in an inconsistent order. - let raw_epevent_ptr: *mut libc::epoll_event = match event { - Some(epevent) => { - //TODO: Shoud be const. - // Cast const to mut to be compatiable with the ocall from rust sdk. - &mut epevent.to_raw() - } + //TODO: Shoud be const. + // Cast const to mut to be compatiable with the ocall from rust sdk. + let mut epevent = event.map(|e| e.to_raw()); + let raw_epevent_ptr: *mut libc::epoll_event = match epevent { + Some(ref mut e) => e as *mut _, _ => std::ptr::null_mut(), };