disable core dumps for panic-uninitialized-zeroed · rust-lang/rust@ef95c63 (original) (raw)

`@@ -5,16 +5,20 @@

`

5

5

`//@ [strict]compile-flags: -Zstrict-init-checks

`

6

6

`//@ needs-subprocess

`

7

7

`//@ ignore-backends: gcc

`

``

8

`+

//@ edition:2024

`

8

9

``

9

10

`#![allow(deprecated, invalid_value)]

`

10

``

`-

#![feature(never_type)]

`

``

11

`+

#![feature(never_type, rustc_private)]

`

11

12

``

12

13

`use std::{

`

13

14

` mem::{self, MaybeUninit, ManuallyDrop},

`

14

15

` ptr::NonNull,

`

15

16

` num,

`

16

17

`};

`

17

18

``

``

19

`+

#[cfg(target_os = "linux")]

`

``

20

`+

extern crate libc;

`

``

21

+

18

22

`#[allow(dead_code)]

`

19

23

`struct Foo {

`

20

24

`x: u8,

`

`@@ -108,6 +112,17 @@ fn test_panic_msg_only_if_strict(op: impl (FnOnce() -> T) + 'static, msg: &st

`

108

112

``

109

113

`fn main() {

`

110

114

`unsafe {

`

``

115

`+

#[cfg(target_os = "linux")]

`

``

116

`+

{

`

``

117

`+

// This test causes a large amount of crashes. If a system

`

``

118

`+

// has a /proc/sys/kernel/core_pattern that uploads core dumps enabled,

`

``

119

`+

// it will take a long time to complete. Set dumpable to 0 to avoid that.

`

``

120

`+

if libc::prctl(libc::PR_SET_DUMPABLE, 0) < 0 {

`

``

121

`+

let err = std::io::Error::last_os_error();

`

``

122

`+

panic!("failed to disable core dumps {err:?}");

`

``

123

`+

}

`

``

124

`+

}

`

``

125

+

111

126

`// Uninhabited types

`

112

127

`test_panic_msg(

`

113

128

` || mem::uninitialized::<!>(),

`