Move large structure off the stack. am: 50270d3ef2 am: de858ed3a4 am: 2a286501e6
am: 591a2eb3f3

Change-Id: Iefda17599fdb15481510536bd0d1bc3d103b763e
diff --git a/src/os-linux.c b/src/os-linux.c
index 7062a1b..8dc1ebf 100644
--- a/src/os-linux.c
+++ b/src/os-linux.c
@@ -40,7 +40,7 @@
   struct map_info *map_list = NULL;
   struct map_info *cur_map;
   unw_addr_space_t as = NULL;
-  struct unw_addr_space local_as;
+  struct unw_addr_space* local_as = NULL;
   void* as_arg = NULL;
 
   if (maps_init (&mi, pid) < 0)
@@ -100,8 +100,14 @@
                 {
                   if (map_create_type == UNW_MAP_CREATE_LOCAL)
                     {
-                      as = &local_as;
-                      unw_local_access_addr_space_init (as);
+                      // This is a very large structure, so allocate it.
+                      if (local_as == NULL)
+                        local_as = (struct unw_addr_space*) malloc(sizeof(*local_as));
+                      if (local_as != NULL)
+                        {
+                          as = local_as;
+                          unw_local_access_addr_space_init (as);
+                        }
                     }
                   else
                     {
@@ -147,6 +153,8 @@
       _UPT_destroy (as_arg);
     }
 
+  free(local_as);
+
   return map_list;
 }
 /* End of ANDROID update. */