Skip to content

Commit 620599e

Browse files
committed
Remove extern on the pub fn rust_oom lang item in libstd, to match ABI of the declaration in liballoc
This turned out to be important on Windows. Calling `handle_alloc_error(Layout::new::<[u8; 42]>())` caused: ``` Exception thrown at 0x00007FF7C70DC399 in a.exe: 0xC0000005: Access violation reading location 0x000000000000002A. ``` 0x2A equals 42, so it looks like the `Layout::size` field of type `usize` was interpreted as a pointer to read from.
1 parent c6807bb commit 620599e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libstd/alloc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ fn default_alloc_error_hook(layout: Layout) {
127127
#[doc(hidden)]
128128
#[lang = "oom"]
129129
#[unstable(feature = "alloc_internals", issue = "0")]
130-
pub extern fn rust_oom(layout: Layout) -> ! {
130+
pub fn rust_oom(layout: Layout) -> ! {
131131
let hook = HOOK.load(Ordering::SeqCst);
132132
let hook: fn(Layout) = if hook.is_null() {
133133
default_alloc_error_hook

0 commit comments

Comments
 (0)