aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_db_hash.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2015-04-08 17:02:15 +0200
committerSverker Eriksson <[email protected]>2015-04-08 17:02:15 +0200
commita4d1a73370dffa6ac96ee70693fd1bd335bd70fe (patch)
tree83a69c294e8cd1c620d7d07408db08dcc5d1c011 /erts/emulator/beam/erl_db_hash.c
parent64bebeaf45403feeac45a8c2b6226d6bc8b71b72 (diff)
downloadotp-a4d1a73370dffa6ac96ee70693fd1bd335bd70fe.tar.gz
otp-a4d1a73370dffa6ac96ee70693fd1bd335bd70fe.tar.bz2
otp-a4d1a73370dffa6ac96ee70693fd1bd335bd70fe.zip
erts: Fix ets bug in debug VM
Symptom: ASSERT(segtab[seg_ix] == NULL) in alloc_seg() fails. Remedy: Make sure we set segment pointer to NULL in free_seg() even when we switch to smaller segtab.
Diffstat (limited to 'erts/emulator/beam/erl_db_hash.c')
-rw-r--r--erts/emulator/beam/erl_db_hash.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/erts/emulator/beam/erl_db_hash.c b/erts/emulator/beam/erl_db_hash.c
index 06dac8f161..b1d9eb84bc 100644
--- a/erts/emulator/beam/erl_db_hash.c
+++ b/erts/emulator/beam/erl_db_hash.c
@@ -2402,10 +2402,10 @@ static int alloc_seg(DbTableHash *tb)
*/
static int free_seg(DbTableHash *tb, int free_records)
{
- int seg_ix = (tb->nslots >> SEGSZ_EXP) - 1;
+ const int seg_ix = (tb->nslots >> SEGSZ_EXP) - 1;
+ struct segment** const segtab = SEGTAB(tb);
+ struct ext_segment* const top = (struct ext_segment*) segtab[seg_ix];
int bytes;
- struct segment** segtab = SEGTAB(tb);
- struct ext_segment* top = (struct ext_segment*) segtab[seg_ix];
int nrecords = 0;
ASSERT(top != NULL);
@@ -2468,7 +2468,7 @@ static int free_seg(DbTableHash *tb, int free_records)
(void*)top, bytes);
#ifdef DEBUG
if (seg_ix > 0) {
- if (seg_ix < tb->nsegs) SEGTAB(tb)[seg_ix] = NULL;
+ segtab[seg_ix] = NULL;
} else {
SET_SEGTAB(tb, NULL);
}