]> git.lizzy.rs Git - rust.git/commitdiff
Remove `extern` on the `pub fn rust_oom` lang item in libstd, to match ABI of the...
authorSimon Sapin <simon.sapin@exyr.org>
Sun, 8 Jul 2018 14:07:08 +0000 (16:07 +0200)
committerSimon Sapin <simon.sapin@exyr.org>
Mon, 9 Jul 2018 21:13:24 +0000 (23:13 +0200)
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.

src/libstd/alloc.rs

index f6cecbea11f8d89fefbf1114a74e4dfaf139d3bd..cfdfbe1357d5ded136b80946476e0cc5391670fd 100644 (file)
@@ -127,7 +127,7 @@ fn default_alloc_error_hook(layout: Layout) {
 #[doc(hidden)]
 #[lang = "oom"]
 #[unstable(feature = "alloc_internals", issue = "0")]
-pub extern fn rust_oom(layout: Layout) -> ! {
+pub fn rust_oom(layout: Layout) -> ! {
     let hook = HOOK.load(Ordering::SeqCst);
     let hook: fn(Layout) = if hook.is_null() {
         default_alloc_error_hook