4 Commits
1.0.2 ... 1.0.3

Author SHA1 Message Date
Jason Evans
e139ab8b4f Merge branch 'dev' 2010-08-12 12:11:58 -07:00
Jason Evans
dcd15098a8 Move assert() calls up in arena_run_reg_alloc().
Move assert() calls up in arena_run_reg_alloc(), so that a corrupt
pointer will likely be caught by an assertion *before* it is
dereferenced.
2010-08-05 12:13:42 -07:00
Jason Evans
2541e1b083 Add a missing mutex unlock in malloc_init_hard().
If multiple threads race to initialize malloc, the loser(s) busy-wait
until initialization is complete.  Add a missing mutex lock so that the
loser(s) properly release the initialization mutex.  Under some
race conditions, this flaw could have caused one or more threads to
become permanently blocked.

Reported by Terrell Magee.
2010-07-22 11:35:59 -07:00
Jason Evans
b43b7750a6 Fix the libunwind version of prof_backtrace().
Fix the libunwind version of prof_backtrace() to set the backtrace depth
for all possible code paths.  This fixes the zero-length backtrace
problem when using libunwind.
2010-06-04 15:10:43 -07:00
3 changed files with 6 additions and 6 deletions

View File

@@ -254,7 +254,6 @@ arena_run_reg_alloc(arena_run_t *run, arena_bin_t *bin)
run->nfree--; run->nfree--;
ret = run->avail; ret = run->avail;
if (ret != NULL) { if (ret != NULL) {
run->avail = *(void **)ret;
/* Double free can cause assertion failure.*/ /* Double free can cause assertion failure.*/
assert(ret != NULL); assert(ret != NULL);
/* Write-after free can cause assertion failure. */ /* Write-after free can cause assertion failure. */
@@ -264,6 +263,7 @@ arena_run_reg_alloc(arena_run_t *run, arena_bin_t *bin)
assert(((uintptr_t)ret - ((uintptr_t)run + assert(((uintptr_t)ret - ((uintptr_t)run +
(uintptr_t)bin->reg0_offset)) % (uintptr_t)bin->reg_size == (uintptr_t)bin->reg0_offset)) % (uintptr_t)bin->reg_size ==
0); 0);
run->avail = *(void **)ret;
return (ret); return (ret);
} }
ret = run->next; ret = run->next;

View File

@@ -324,6 +324,7 @@ malloc_init_hard(void)
CPU_SPINWAIT; CPU_SPINWAIT;
malloc_mutex_lock(&init_lock); malloc_mutex_lock(&init_lock);
} while (malloc_initialized == false); } while (malloc_initialized == false);
malloc_mutex_unlock(&init_lock);
return (false); return (false);
} }

View File

@@ -239,17 +239,16 @@ prof_backtrace(prof_bt_t *bt, unsigned nignore, unsigned max)
} }
/* /*
* Iterate over stack frames until there are no more. Heap-allocate * Iterate over stack frames until there are no more, or until no space
* and iteratively grow a larger bt if necessary. * remains in bt.
*/ */
for (i = 0; i < max; i++) { for (i = 0; i < max; i++) {
unw_get_reg(&cursor, UNW_REG_IP, (unw_word_t *)&bt->vec[i]); unw_get_reg(&cursor, UNW_REG_IP, (unw_word_t *)&bt->vec[i]);
bt->len++;
err = unw_step(&cursor); err = unw_step(&cursor);
if (err <= 0) { if (err <= 0)
bt->len = i;
break; break;
} }
}
} }
#else #else
static void static void