about summary refs log tree commit diff
path: root/src/liballoc_system
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-10-29 17:28:07 -0700
committerGitHub <noreply@github.com>2016-10-29 17:28:07 -0700
commit248e7b302a92da0ae829560fde721a62119c2c65 (patch)
tree21cf9522456ba5072bed4e2dd42404a308c260f0 /src/liballoc_system
parent2b262cf1116efc15d729a50cdc0b0b01953b7668 (diff)
parentb3e8c4c2be593562085fca03a973fb2d917e5184 (diff)
downloadrust-248e7b302a92da0ae829560fde721a62119c2c65.tar.gz
rust-248e7b302a92da0ae829560fde721a62119c2c65.zip
Auto merge of #37399 - retep998:heap-of-trouble, r=alexcrichton
Print out the error when HeapFree failures do occur

cc https://github.com/rust-lang/rust/issues/37395

I'd prefer to use `assert!` instead of `debug_assert!` if the cost is acceptable.

r? @alexcrichton
Diffstat (limited to 'src/liballoc_system')
-rw-r--r--src/liballoc_system/lib.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/liballoc_system/lib.rs b/src/liballoc_system/lib.rs
index b380ba180f4..a4fabb5a2c9 100644
--- a/src/liballoc_system/lib.rs
+++ b/src/liballoc_system/lib.rs
@@ -166,6 +166,7 @@ mod imp {
         fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) -> LPVOID;
         fn HeapReAlloc(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID, dwBytes: SIZE_T) -> LPVOID;
         fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID) -> BOOL;
+        fn GetLastError() -> DWORD;
     }
 
     #[repr(C)]
@@ -230,11 +231,11 @@ mod imp {
     pub unsafe fn deallocate(ptr: *mut u8, _old_size: usize, align: usize) {
         if align <= MIN_ALIGN {
             let err = HeapFree(GetProcessHeap(), 0, ptr as LPVOID);
-            debug_assert!(err != 0);
+            debug_assert!(err != 0, "Failed to free heap memory: {}", GetLastError());
         } else {
             let header = get_header(ptr);
             let err = HeapFree(GetProcessHeap(), 0, header.0 as LPVOID);
-            debug_assert!(err != 0);
+            debug_assert!(err != 0, "Failed to free heap memory: {}", GetLastError());
         }
     }