about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristiaan Dirkx <christiaan@dirkx.email>2021-04-29 16:05:10 +0200
committerChristiaan Dirkx <christiaan@dirkx.email>2021-05-19 15:01:52 +0200
commit236705f3c30905623f97dc8887c83db520eb27c1 (patch)
tree3401d07479d3ee044418fc8178717412d3060957
parentb987f74f05b3fbeb81eed27c43678dc71cdab8cf (diff)
downloadrust-236705f3c30905623f97dc8887c83db520eb27c1.tar.gz
rust-236705f3c30905623f97dc8887c83db520eb27c1.zip
Replace `sys_common::util::report_overflow` with `rterr!`
-rw-r--r--library/std/src/sys/unix/stack_overflow.rs8
-rw-r--r--library/std/src/sys/windows/stack_overflow.rs7
-rw-r--r--library/std/src/sys_common/util.rs9
3 files changed, 10 insertions, 14 deletions
diff --git a/library/std/src/sys/unix/stack_overflow.rs b/library/std/src/sys/unix/stack_overflow.rs
index 2a487fff54a..72fd48278bc 100644
--- a/library/std/src/sys/unix/stack_overflow.rs
+++ b/library/std/src/sys/unix/stack_overflow.rs
@@ -42,6 +42,7 @@ mod imp {
     use crate::io;
     use crate::mem;
     use crate::ptr;
+    use crate::thread;
 
     use libc::MAP_FAILED;
     use libc::{mmap, munmap};
@@ -95,15 +96,16 @@ mod imp {
         info: *mut libc::siginfo_t,
         _data: *mut libc::c_void,
     ) {
-        use crate::sys_common::util::report_overflow;
-
         let guard = thread_info::stack_guard().unwrap_or(0..0);
         let addr = siginfo_si_addr(info);
 
         // If the faulting address is within the guard page, then we print a
         // message saying so and abort.
         if guard.start <= addr && addr < guard.end {
-            report_overflow();
+            rterr!(
+                "\nthread '{}' has overflowed its stack\n",
+                thread::current().name().unwrap_or("<unknown>")
+            );
             rtabort!("stack overflow");
         } else {
             // Unregister ourselves by reverting back to the default behavior.
diff --git a/library/std/src/sys/windows/stack_overflow.rs b/library/std/src/sys/windows/stack_overflow.rs
index 39efb778207..24ba35ad17e 100644
--- a/library/std/src/sys/windows/stack_overflow.rs
+++ b/library/std/src/sys/windows/stack_overflow.rs
@@ -1,7 +1,7 @@
 #![cfg_attr(test, allow(dead_code))]
 
 use crate::sys::c;
-use crate::sys_common::util::report_overflow;
+use crate::thread;
 
 pub struct Handler;
 
@@ -24,7 +24,10 @@ extern "system" fn vectored_handler(ExceptionInfo: *mut c::EXCEPTION_POINTERS) -
         let code = rec.ExceptionCode;
 
         if code == c::EXCEPTION_STACK_OVERFLOW {
-            report_overflow();
+            rterr!(
+                "\nthread '{}' has overflowed its stack\n",
+                thread::current().name().unwrap_or("<unknown>")
+            );
         }
         c::EXCEPTION_CONTINUE_SEARCH
     }
diff --git a/library/std/src/sys_common/util.rs b/library/std/src/sys_common/util.rs
index b8cae26d04c..f7072cc5011 100644
--- a/library/std/src/sys_common/util.rs
+++ b/library/std/src/sys_common/util.rs
@@ -1,18 +1,9 @@
 use crate::fmt;
 use crate::io::prelude::*;
 use crate::sys::stdio::panic_output;
-use crate::thread;
 
 pub fn dumb_print(args: fmt::Arguments<'_>) {
     if let Some(mut out) = panic_output() {
         let _ = out.write_fmt(args);
     }
 }
-
-#[allow(dead_code)] // stack overflow detection not enabled on all platforms
-pub unsafe fn report_overflow() {
-    dumb_print(format_args!(
-        "\nthread '{}' has overflowed its stack\n",
-        thread::current().name().unwrap_or("<unknown>")
-    ));
-}