dgaudet 98/01/26 18:37:52
Modified: src/main alloc.c Log: more pool debugging -- copy_table() and overlay_tables() have implicit assumptions about the pool relationships of their arguments. There are actually some bugs in the core code I'll fix in a few minutes. Revision Changes Path 1.70 +24 -0 apachen/src/main/alloc.c Index: alloc.c =================================================================== RCS file: /export/home/cvs/apachen/src/main/alloc.c,v retrieving revision 1.69 retrieving revision 1.70 diff -u -r1.69 -r1.70 --- alloc.c 1998/01/26 19:50:10 1.69 +++ alloc.c 1998/01/27 02:37:51 1.70 @@ -873,6 +873,15 @@ { table *new = palloc(p, sizeof(table)); +#ifdef POOL_DEBUG + /* we don't copy keys and values, so it's necessary that t->a.pool + * have a life span at least as long as p + */ + if (!pool_is_ancestor(t->a.pool, p)) { + fprintf(stderr, "copy_table: t's pool is not an ancestor of p\n"); + abort(); + } +#endif make_array_core(&new->a, p, t->a.nalloc, sizeof(table_entry)); memcpy(new->a.elts, t->a.elts, t->a.nelts * sizeof(table_entry)); new->a.nelts = t->a.nelts; @@ -1083,6 +1092,21 @@ API_EXPORT(table *) overlay_tables(pool *p, const table *overlay, const table *base) { table *res; + +#ifdef POOL_DEBUG + /* we don't copy keys and values, so it's necessary that + * overlay->a.pool and base->a.pool have a life span at least + * as long as p + */ + if (!pool_is_ancestor(overlay->a.pool, p)) { + fprintf(stderr, "overlay_tables: overlay's pool is not an ancestor of p\n"); + abort(); + } + if (!pool_is_ancestor(base->a.pool, p)) { + fprintf(stderr, "overlay_tables: base's pool is not an ancestor of p\n"); + abort(); + } +#endif res = palloc(p, sizeof(table)); /* behave like append_arrays */