[asterisk-commits] tilghman: branch tilghman/malloc_hold r208885 - /team/tilghman/malloc_hold/main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Jul 25 11:28:12 CDT 2009
Author: tilghman
Date: Sat Jul 25 11:28:08 2009
New Revision: 208885
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=208885
Log:
Fix remaining crash issues
Modified:
team/tilghman/malloc_hold/main/astmm.c
Modified: team/tilghman/malloc_hold/main/astmm.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/tilghman/malloc_hold/main/astmm.c?view=diff&rev=208885&r1=208884&r2=208885
==============================================================================
--- team/tilghman/malloc_hold/main/astmm.c (original)
+++ team/tilghman/malloc_hold/main/astmm.c Sat Jul 25 11:28:08 2009
@@ -131,7 +131,7 @@
unsigned int free_lineno;
unsigned int freetime;
int mperm;
- int violation;
+ int operation;
void *vlocation;
#endif
char alloc_file[40];
@@ -280,7 +280,7 @@
reg->next = NULL;
reg->mperm = PROT_NONE;
- reg->violation = 0;
+ reg->operation = 0;
reg->vlocation = NULL;
reg->freetime = now;
ast_copy_string(reg->free_file, file, sizeof(reg->free_file));
@@ -646,7 +646,7 @@
cur->alloc_func, cur->alloc_file, cur->alloc_lineno,
cur->free_func, cur->free_file, cur->free_lineno);
memset(&violations[last_seen_violation], 0, sizeof(violations[0]));
- cur->violation = 0;
+ cur->operation = 0;
cur->mperm = PROT_NONE;
mprotect(cur, cur->fullsize, PROT_NONE);
}
@@ -657,7 +657,7 @@
while ((cur = regions[SOME_PRIME]) && !mprotect(cur, sizeof(*cur), PROT_READ) && cur->freetime < time(NULL) - 120) {
int i;
- if (mprotect(cur, cur->fullsize, PROT_READ)) {
+ if (mprotect(cur, cur->fullsize, PROT_READ | PROT_WRITE | PROT_EXEC)) {
astmm_log("ERROR: cannot access freed memory at %p, (originally in %s of %s, line %d, freed in %s of %s, line %d)\n",
cur->data, cur->alloc_func, cur->alloc_file, cur->alloc_lineno, cur->free_func, cur->free_file, cur->free_lineno);
/* XXX crash, perhaps? XXX (should not ever happen) */
@@ -671,13 +671,13 @@
#if 0 /* Verification that this thread is running only */
astmm_log("Freeing memory at %p (size %d, originally allocated in %s of %s, line %d)\n", cur->data, cur->len, cur->alloc_func, cur->alloc_file, cur->alloc_lineno);
#endif
- if (cur->violation) {
+ if (cur->operation) {
for (i = 0; i < ARRAY_LEN(violations); i++) {
if (cur == violations[i].base_addr) {
astmm_log("Intercepted invalid %s to %p (%p+%d), originally allocated in %s at %s:%d and freed in %s at %s:%d\n",
- violations[last_seen_violation].error == PROT_READ ? "read" : "write",
- violations[last_seen_violation].violation, cur->data,
- violations[last_seen_violation].violation - (void *) cur->data,
+ violations[i].error == PROT_READ ? "read" : "write",
+ violations[i].violation, cur->data,
+ violations[i].violation - (void *) cur->data,
cur->alloc_func, cur->alloc_file, cur->alloc_lineno,
cur->free_func, cur->free_file, cur->free_lineno);
memset(&violations[i], 0, sizeof(violations[i]));
@@ -709,7 +709,7 @@
{
struct ast_region *cur;
- if (signal != SIGSEGV) {
+ if (signal != SIGSEGV || info->si_code == SI_SIGIO) {
return;
}
@@ -755,8 +755,8 @@
mprotect(cur, cur->fullsize, newperm);
cur->mperm = newperm;
if (cur->vlocation == info->si_addr) {
- cur->violation = PROT_WRITE;
- if (violations[last_violation].base_addr == cur) {
+ cur->operation = PROT_WRITE;
+ if (violations[last_violation].base_addr == cur && violations[last_violation].violation == info->si_addr) {
violations[last_violation].error = PROT_WRITE;
}
}
@@ -765,7 +765,7 @@
mprotect(cur, cur->fullsize, PROT_READ | PROT_WRITE);
cur->mperm = PROT_READ;
cur->vlocation = info->si_addr;
- cur->violation = PROT_READ;
+ cur->operation = PROT_READ;
mprotect(cur, cur->fullsize, cur->mperm);
if (++last_violation > ARRAY_LEN(violations)) {
@@ -774,7 +774,7 @@
violations[last_violation].base_addr = cur;
violations[last_violation].violation = info->si_addr;
violations[last_violation].when = time(NULL);
- violations[last_violation].error = cur->violation;
+ violations[last_violation].error = cur->operation;
}
/*!
@@ -806,7 +806,7 @@
while ((reg = regions[SOME_PRIME])) {
mprotect(reg, sizeof(*reg), PROT_READ | PROT_WRITE);
mprotect(reg, reg->fullsize, PROT_READ | PROT_WRITE);
- reg->violation = 0;
+ reg->operation = 0;
regions[SOME_PRIME] = reg->next;
free(reg);
}
More information about the asterisk-commits
mailing list