On Tue, Nov 24, 2009 at 12:12 PM, Arun Sharma <[email protected]> wrote:

> You're right. This part is broken for dwarf. We'll need to fix it along the
> lines of src/ia64/Gscript.c

Tricky (unless we drastically reduce cache size): current
sizeof(local_addr_space) on x86_64 is 43664, and adding this much
TLS to each thread may run into glibc issue: glibc does not
automatically add required TLS space at pthread_create, so if you
specify e.g. 64K stack, pthread_create will fail with EINVAL just
because you linked to libunwind.

> Agree that fix#1 is suboptimal. The choice is really between fix #2 and a
> fixed UNW_CACHE_PER_THREAD.

Hmm, I don't think that's the choice: libunwind *should* work with either!

Attached is a fix#2A, which removes the race for UNW_CACHE_GLOBAL,
but doesn't penalize UNW_CACHE_PER_THREAD (except for a single branch).

Thanks,
-- 
Paul Pluzhnikov
diff --git a/src/dwarf/Gparser.c b/src/dwarf/Gparser.c
index b77bde2..2c082d5 100644
--- a/src/dwarf/Gparser.c
+++ b/src/dwarf/Gparser.c
@@ -784,12 +784,13 @@ HIDDEN int
 dwarf_find_save_locs (struct dwarf_cursor *c)
 {
   dwarf_state_record_t sr;
-  dwarf_reg_state_t *rs;
+  dwarf_reg_state_t *rs, rs_copy;
   struct dwarf_rs_cache *cache;
   int ret = 0;
   intrmask_t saved_mask;
+  const unw_caching_policy_t caching_policy = c->as->caching_policy;
 
-  if (c->as->caching_policy == UNW_CACHE_NONE)
+  if (caching_policy == UNW_CACHE_NONE)
     return uncached_dwarf_find_save_locs (c);
 
   cache = get_rs_cache(c->as, &saved_mask);
@@ -816,6 +817,12 @@ dwarf_find_save_locs (struct dwarf_cursor *c)
       put_unwind_info (c, &c->pi);
     }
 
+  if (likely (caching_policy == UNW_CACHE_GLOBAL))
+    {
+      memcpy (&rs_copy, rs, sizeof (rs_copy));
+      rs = &rs_copy;
+    }
+
   put_rs_cache (c->as, cache, &saved_mask);
   if ((ret = apply_reg_state (c, rs)) < 0)
     return ret;
_______________________________________________
Libunwind-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/libunwind-devel

Reply via email to