Branch: Tag:

2014-12-04

2014-12-04 19:23:03 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Mappings: Compat: Reduce aggressiveness of rehash gc.

Non-reference counted values are now counted as multi-referenced
by the rehash gc. This fixes issues where elements are lost in
double-weak mappings due to either the index or the value being
a non-reference counted value.

350:    }    break;    case MAPPING_WEAK: -  if ((TYPEOF(from->ind) <= MAX_REF_TYPE) && -  (*from->ind.u.refs > 1) && -  (TYPEOF(from->val) <= MAX_REF_TYPE) && -  (*from->val.u.refs > 1)) { +  /* NB: Compat: Unreference counted values are counted +  * as multi-referenced here. +  */ +  if (((TYPEOF(from->ind) > MAX_REF_TYPE) || +  (*from->ind.u.refs > 1)) && +  ((TYPEOF(from->val) > MAX_REF_TYPE) || +  (*from->val.u.refs > 1))) {    goto keep_keypair;    }    break;
440:    }    break;    case MAPPING_WEAK: -  if ((TYPEOF(from->ind) <= MAX_REF_TYPE) && -  (*from->ind.u.refs > 1) && -  (TYPEOF(from->val) <= MAX_REF_TYPE) && -  (*from->val.u.refs > 1)) { +  /* NB: Compat: Unreference counted values are counted +  * as multi-referenced here. +  */ +  if (((TYPEOF(from->ind) > MAX_REF_TYPE) || +  (*from->ind.u.refs > 1)) && +  ((TYPEOF(from->val) > MAX_REF_TYPE) || +  (*from->val.u.refs > 1))) {    goto keep_keypair;    }    break;