Author: sewardj
Date: 2007-12-15 23:08:35 +0000 (Sat, 15 Dec 2007)
New Revision: 7301

Log:
Print a nice message if allocation of the stack fails, rather than just
asserting.

Modified:
   trunk/coregrind/m_initimg/initimg-linux.c


Modified: trunk/coregrind/m_initimg/initimg-linux.c
===================================================================
--- trunk/coregrind/m_initimg/initimg-linux.c   2007-12-15 22:13:05 UTC (rev 
7300)
+++ trunk/coregrind/m_initimg/initimg-linux.c   2007-12-15 23:08:35 UTC (rev 
7301)
@@ -44,6 +44,7 @@
 #include "pub_core_machine.h"
 #include "pub_core_ume.h"
 #include "pub_core_options.h"
+#include "pub_core_syscall.h"
 #include "pub_core_tooliface.h"       /* VG_TRACK */
 #include "pub_core_threadstate.h"     /* ThreadArchState */
 #include "pub_core_initimg.h"         /* self */
@@ -572,19 +573,32 @@
 
      /* Create a shrinkable reservation followed by an anonymous
         segment.  Together these constitute a growdown stack. */
+     res = VG_(mk_SysRes_Error)(0);
      ok = VG_(am_create_reservation)(
              resvn_start,
              resvn_size -inner_HACK,
              SmUpper, 
              anon_size +inner_HACK
           );
+     if (ok) {
+        /* allocate a stack - mmap enough space for the stack */
+        res = VG_(am_mmap_anon_fixed_client)(
+                 anon_start -inner_HACK,
+                 anon_size +inner_HACK,
+                VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC
+             );
+     }
+     if ((!ok) || res.isError) {
+        /* Allocation of the stack failed.  We have to stop. */
+        VG_(printf)("valgrind: "
+                    "I failed to allocate space for the application's 
stack.\n");
+        VG_(printf)("valgrind: "
+                    "This may be the result of a very large 
--max-stackframe=\n");
+        VG_(printf)("valgrind: setting.  Cannot continue.  Sorry.\n\n");
+        VG_(exit)(0);
+     }
+
      vg_assert(ok);
-     /* allocate a stack - mmap enough space for the stack */
-     res = VG_(am_mmap_anon_fixed_client)(
-              anon_start -inner_HACK,
-              anon_size +inner_HACK,
-             VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC
-          );
      vg_assert(!res.isError); 
    }
 


-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Valgrind-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-developers

Reply via email to