From da7b813fa9da617494048b8acee3d6ec21ba8a03 Mon Sep 17 00:00:00 2001
From: jD91mZM2 <me@krake.one>
Date: Sat, 15 Aug 2020 17:22:34 +0200
Subject: [PATCH] Investigate why user heap isn't mapped

Took me way too long to spot this :D
---
 src/syscall/process.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/syscall/process.rs b/src/syscall/process.rs
index e051197..9062d5f 100644
--- a/src/syscall/process.rs
+++ b/src/syscall/process.rs
@@ -455,14 +455,14 @@ pub fn clone(flags: CloneFlags, stack_base: usize) -> Result<ContextId> {
 
                 // Copy user heap mapping, if found
                 if let Some(heap_shared) = heap_opt {
-                    //TODO: find out why this gets unmapped (perhaps it is never mapped)
+                    // This will not always be mapped. `context.heap` starts off
+                    // with a size of zero, and then any call to `brk` increases
+                    // it. But, if `brk` doesn't increase it, it's zero.
                     if let Some(frame) = active_table.p4()[crate::USER_HEAP_PML4].pointed_frame() {
                         let flags = active_table.p4()[crate::USER_HEAP_PML4].flags();
                         active_table.with(&mut new_table, &mut temporary_page, |mapper| {
                             mapper.p4_mut()[crate::USER_HEAP_PML4].set(frame, flags);
                         });
-                    } else {
-                        println!("clone: user heap not mapped for {:X?}", heap_shared);
                     }
                     context.heap = Some(heap_shared);
                 }
-- 
GitLab