Skip to content

Commit 7b8f93e

Browse files
committed
Add comments about using debug_assert
1 parent e457b77 commit 7b8f93e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

library/std/src/sys/pal/windows/stack_overflow.rs

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use crate::thread;
66
/// Reserve stack space for use in stack overflow exceptions.
77
pub unsafe fn reserve_stack() {
88
let result = c::SetThreadStackGuarantee(&mut 0x5000);
9+
// Reserving stack space is not critical so we allow it to fail in the released build of libstd.
10+
// We still use debug assert here so that CI will test that we haven't made a mistake calling the function.
911
debug_assert_ne!(result, 0, "failed to reserve stack space for exception handling");
1012
}
1113

@@ -26,6 +28,8 @@ unsafe extern "system" fn vectored_handler(ExceptionInfo: *mut c::EXCEPTION_POIN
2628

2729
pub unsafe fn init() {
2830
let result = c::AddVectoredExceptionHandler(0, Some(vectored_handler));
31+
// Similar to the above, adding the stack overflow handler is allowed to fail
32+
// but a debug assert is used so CI will still test that it normally works.
2933
debug_assert!(!result.is_null(), "failed to install exception handler");
3034
// Set the thread stack guarantee for the main thread.
3135
reserve_stack();

0 commit comments

Comments
 (0)