Skip to content

Commit d2c8377

Browse files
committed
Let stack_overflow::imp::cleanup call drop_handler directly
instead of through the Drop impl for Handler
1 parent bf9e6e5 commit d2c8377

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

library/std/src/sys/unix/stack_overflow.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub use self::imp::cleanup;
66
pub use self::imp::init;
77

88
pub struct Handler {
9-
_data: *mut libc::c_void,
9+
data: *mut libc::c_void,
1010
}
1111

1212
impl Handler {
@@ -15,14 +15,14 @@ impl Handler {
1515
}
1616

1717
fn null() -> Handler {
18-
Handler { _data: crate::ptr::null_mut() }
18+
Handler { data: crate::ptr::null_mut() }
1919
}
2020
}
2121

2222
impl Drop for Handler {
2323
fn drop(&mut self) {
2424
unsafe {
25-
drop_handler(self);
25+
drop_handler(self.data);
2626
}
2727
}
2828
}
@@ -134,12 +134,12 @@ mod imp {
134134
}
135135

136136
let handler = make_handler();
137-
MAIN_ALTSTACK.store(handler._data, Ordering::Relaxed);
137+
MAIN_ALTSTACK.store(handler.data, Ordering::Relaxed);
138138
mem::forget(handler);
139139
}
140140

141141
pub unsafe fn cleanup() {
142-
Handler { _data: MAIN_ALTSTACK.load(Ordering::Relaxed) };
142+
drop_handler(MAIN_ALTSTACK.load(Ordering::Relaxed));
143143
}
144144

145145
unsafe fn get_stackp() -> *mut libc::c_void {
@@ -175,14 +175,14 @@ mod imp {
175175
if stack.ss_flags & SS_DISABLE != 0 {
176176
stack = get_stack();
177177
sigaltstack(&stack, ptr::null_mut());
178-
Handler { _data: stack.ss_sp as *mut libc::c_void }
178+
Handler { data: stack.ss_sp as *mut libc::c_void }
179179
} else {
180180
Handler::null()
181181
}
182182
}
183183

184-
pub unsafe fn drop_handler(handler: &mut Handler) {
185-
if !handler._data.is_null() {
184+
pub unsafe fn drop_handler(data: *mut libc::c_void) {
185+
if !data.is_null() {
186186
let stack = libc::stack_t {
187187
ss_sp: ptr::null_mut(),
188188
ss_flags: SS_DISABLE,
@@ -195,7 +195,7 @@ mod imp {
195195
sigaltstack(&stack, ptr::null_mut());
196196
// We know from `get_stackp` that the alternate stack we installed is part of a mapping
197197
// that started one page earlier, so walk back a page and unmap from there.
198-
munmap(handler._data.sub(page_size()), SIGSTKSZ + page_size());
198+
munmap(data.sub(page_size()), SIGSTKSZ + page_size());
199199
}
200200
}
201201
}
@@ -219,5 +219,5 @@ mod imp {
219219
super::Handler::null()
220220
}
221221

222-
pub unsafe fn drop_handler(_handler: &mut super::Handler) {}
222+
pub unsafe fn drop_handler(_data: *mut libc::c_void) {}
223223
}

0 commit comments

Comments
 (0)