Branch: Tag:

2010-09-20

2010-09-20 14:49:32 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Added some temporary nonoptional consistency checks for the string hash table.
These will be made optional when the bug has been fixed.

Rev: src/stralloc.c:1.164

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: stralloc.c,v 1.163 2010/04/29 15:08:51 grubba Exp $ + || $Id: stralloc.c,v 1.164 2010/09/20 14:49:32 grubba Exp $   */      #include "global.h"
24:   #include <ctype.h>   #include <math.h>    - RCSID("$Id: stralloc.c,v 1.163 2010/04/29 15:08:51 grubba Exp $"); + RCSID("$Id: stralloc.c,v 1.164 2010/09/20 14:49:32 grubba Exp $");      /* #define STRALLOC_USE_PRIMES */   
376:    !MEMCMP(curr->str, s,len<<size_shift))) /* found it */    {    *prev = curr->next; +  if (*base == curr) { +  Pike_fatal("String circularity imminent (FIND).\n"); +  }    curr->next = *base;    *base = curr;    UNLOCK_BUCKET(hval);
385: Inside #if undefined(HASH_PREFIX)
   if (curr->len > HASH_PREFIX)    depth++;   #endif +  if (curr == curr->next) { +  Pike_fatal("String circularity detected for string 0x%lx.\n", +  (unsigned long)curr);    } -  +  }   #ifndef HASH_PREFIX    /* These heuruistics might require tuning! /Hubbe */    if (depth > need_more_hash_prefix_depth)
428:    if (curr == s) /* found it */    {    *prev=curr->next; +  if (*base == curr) { +  Pike_fatal("String circularity imminent (PROPAGATE).\n"); +  }    curr->next=*base;    *base=curr;    return curr;
455:       /* Reverse the hash list. */    while ((next = s->next)) { +  if (prev == s) { +  Pike_fatal("String circularity detected for string 0x%lx (REVERSE).\n", +  (unsigned long)s); +  }    s->next = prev;    prev = s;    s = next;
465:    do {    ptrdiff_t h = HMODULO(s->hval);    next = s->next; +  if (base_table[h] == s) { +  Pike_fatal("String circularity imminent (REHASH).\n"); +  }    s->next = base_table[h];    base_table[h] = s;    } while ((s = next));
590:    LOCK_BUCKET(hval);    h=HMODULO(hval);    s->refs = 0; +  if (base_table[h] == s) { +  Pike_fatal("String circularity imminent (LINK).\n"); +  }    s->next = base_table[h];    base_table[h] = s;    s->hval=hval;
649: Inside #if undefined(HASH_PREFIX)
   tmp2->hval=do_hash(tmp2); /* compute new hash value */    h2=HMODULO(tmp2->hval);    +  if (base_table[h2] == tmp2) { +  Pike_fatal("String circularity imminent (PREFIX).\n"); +  }    tmp2->next=base_table[h2]; /* and re-hash */    base_table[h2]=tmp2;    }