Skip to content

Commit c491116

Browse files
committed
libstd: windows: Disabled stack overflow handling on UWP
The required functions are not available, so hope for the best
1 parent 8c03b14 commit c491116

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/libstd/sys/windows/c.rs

+8
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,11 @@ pub const IMAGE_FILE_MACHINE_ARM64: DWORD = 0xAA64;
299299
#[cfg(feature = "backtrace")]
300300
pub const IMAGE_FILE_MACHINE_ARMNT: DWORD = 0x01c4;
301301

302+
#[cfg(not(target_os = "uwp"))]
302303
pub const EXCEPTION_CONTINUE_SEARCH: LONG = 0;
304+
#[cfg(not(target_os = "uwp"))]
303305
pub const EXCEPTION_STACK_OVERFLOW: DWORD = 0xc00000fd;
306+
#[cfg(not(target_os = "uwp"))]
304307
pub const EXCEPTION_MAXIMUM_PARAMETERS: usize = 15;
305308

306309
pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001;
@@ -502,6 +505,7 @@ pub struct REPARSE_MOUNTPOINT_DATA_BUFFER {
502505
pub ReparseTarget: WCHAR,
503506
}
504507

508+
#[cfg(not(target_os = "uwp"))]
505509
#[repr(C)]
506510
pub struct EXCEPTION_RECORD {
507511
pub ExceptionCode: DWORD,
@@ -512,12 +516,14 @@ pub struct EXCEPTION_RECORD {
512516
pub ExceptionInformation: [LPVOID; EXCEPTION_MAXIMUM_PARAMETERS]
513517
}
514518

519+
#[cfg(not(target_os = "uwp"))]
515520
#[repr(C)]
516521
pub struct EXCEPTION_POINTERS {
517522
pub ExceptionRecord: *mut EXCEPTION_RECORD,
518523
pub ContextRecord: *mut CONTEXT,
519524
}
520525

526+
#[cfg(not(target_os = "uwp"))]
521527
pub type PVECTORED_EXCEPTION_HANDLER = extern "system"
522528
fn(ExceptionInfo: *mut EXCEPTION_POINTERS) -> LONG;
523529

@@ -1116,6 +1122,7 @@ extern "system" {
11161122
lpData: LPVOID,
11171123
pbCancel: LPBOOL,
11181124
dwCopyFlags: DWORD) -> BOOL;
1125+
#[cfg(not(target_os = "uwp"))]
11191126
pub fn AddVectoredExceptionHandler(FirstHandler: ULONG,
11201127
VectoredHandler: PVECTORED_EXCEPTION_HANDLER)
11211128
-> LPVOID;
@@ -1340,6 +1347,7 @@ compat_fn! {
13401347
_dwFlags: DWORD) -> DWORD {
13411348
SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0
13421349
}
1350+
#[cfg(not(target_os = "uwp"))]
13431351
pub fn SetThreadStackGuarantee(_size: *mut c_ulong) -> BOOL {
13441352
SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0
13451353
}

src/libstd/sys/windows/stack_overflow.rs

+13
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#![cfg_attr(test, allow(dead_code))]
22

3+
#[cfg(not(target_os = "uwp"))]
34
use crate::sys_common::util::report_overflow;
5+
#[cfg(not(target_os = "uwp"))]
46
use crate::sys::c;
57

68
pub struct Handler;
79

810
impl Handler {
11+
#[cfg(not(target_os = "uwp"))]
912
pub unsafe fn new() -> Handler {
1013
// This API isn't available on XP, so don't panic in that case and just
1114
// pray it works out ok.
@@ -16,8 +19,14 @@ impl Handler {
1619
}
1720
Handler
1821
}
22+
23+
#[cfg(target_os = "uwp")]
24+
pub fn new() -> Handler {
25+
Handler
26+
}
1927
}
2028

29+
#[cfg(not(target_os = "uwp"))]
2130
extern "system" fn vectored_handler(ExceptionInfo: *mut c::EXCEPTION_POINTERS)
2231
-> c::LONG {
2332
unsafe {
@@ -31,6 +40,7 @@ extern "system" fn vectored_handler(ExceptionInfo: *mut c::EXCEPTION_POINTERS)
3140
}
3241
}
3342

43+
#[cfg(not(target_os = "uwp"))]
3444
pub unsafe fn init() {
3545
if c::AddVectoredExceptionHandler(0, vectored_handler).is_null() {
3646
panic!("failed to install exception handler");
@@ -39,4 +49,7 @@ pub unsafe fn init() {
3949
let _h = Handler::new();
4050
}
4151

52+
#[cfg(target_os = "uwp")]
53+
pub unsafe fn init() {}
54+
4255
pub unsafe fn cleanup() {}

0 commit comments

Comments
 (0)