]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Removed some code from VG_(client_alloc)() that could be left to VG_(mmap)().
authorNicholas Nethercote <n.nethercote@gmail.com>
Sun, 11 Jul 2004 18:01:06 +0000 (18:01 +0000)
committerNicholas Nethercote <n.nethercote@gmail.com>
Sun, 11 Jul 2004 18:01:06 +0000 (18:01 +0000)
Added a comment about stack extension failure.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2476

coregrind/vg_memory.c
coregrind/vg_scheduler.c

index 0e4bcdaf5c9e409abae6dc83959fdfb9261a7885..f179c96400788889c6e27412cf48cb9798cc66b4 100644 (file)
@@ -680,21 +680,16 @@ Addr VG_(client_alloc)(Addr addr, UInt len, UInt prot, UInt sf_flags)
 {
    len = PGROUNDUP(len);
 
-   if (!(sf_flags & SF_FIXED))
-      addr = VG_(find_map_space)(addr, len, True);
+   sk_assert(!(sf_flags & SF_FIXED));
+   sk_assert(0 == addr);
 
-   // Don't do the mapping if we couldn't find space!
-   if (0 == addr)
-      return 0;
-
-   if (VG_(mmap)((void *)addr, len, prot,
-                VKI_MAP_FIXED | VKI_MAP_PRIVATE | VKI_MAP_ANONYMOUS | VKI_MAP_CLIENT,
-                 sf_flags | SF_CORE, -1, 0) == (void *)addr) 
-   {
+   addr = (Addr)VG_(mmap)((void *)addr, len, prot, 
+                          VKI_MAP_PRIVATE | VKI_MAP_ANONYMOUS | VKI_MAP_CLIENT,
+                          sf_flags | SF_CORE, -1, 0);
+   if ((Addr)-1 != addr)
       return addr;
-   }
-
-   return 0;
+   else
+      return 0;
 }
 
 void VG_(client_free)(Addr addr)
index b8efb724f12d2ee0aa9cb7939644dd9e208601ed..05c1b0f75a427392362b36d699adfb45235bfdc3 100644 (file)
@@ -1941,6 +1941,14 @@ void do__apply_in_new_thread ( ThreadId parent_tid,
       new_stack = VG_(client_alloc)(0, new_stk_szb, 
                                    VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC, 
                                    SF_STACK);
+      // Given the low number of threads Valgrind can handle, stack
+      // allocation should pretty much always succeed, so having an
+      // assertion here isn't too bad.  However, probably better would be
+      // this:
+      //
+      //   if (0 == new_stack) 
+      //      SET_PTHREQ_RETVAL(parent_tid, -VKI_EAGAIN);
+      //   
       vg_assert(0 != new_stack);
       VG_(threads)[tid].stack_base = new_stack;
       VG_(threads)[tid].stack_size = new_stk_szb;