diff options
author | Sverker Eriksson <[email protected]> | 2013-04-02 18:47:35 +0200 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2013-04-02 18:47:35 +0200 |
commit | 31bc414dc9639ccf94f9011ed3240c05c6a7f0cb (patch) | |
tree | 4fa609abe1add753f1a372aeb59f430c49c8a4e2 | |
parent | a95050941b2f75856e3ecc6dfc3934d6358bd528 (diff) | |
download | otp-31bc414dc9639ccf94f9011ed3240c05c6a7f0cb.tar.gz otp-31bc414dc9639ccf94f9011ed3240c05c6a7f0cb.tar.bz2 otp-31bc414dc9639ccf94f9011ed3240c05c6a7f0cb.zip |
erts: Fix unabused bug in fixed allocation
Make sure each fix allocator type always allocate the right fixed size.
-rw-r--r-- | erts/emulator/beam/erl_alloc_util.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/erts/emulator/beam/erl_alloc_util.c b/erts/emulator/beam/erl_alloc_util.c index 510b1b47e1..583aeed12d 100644 --- a/erts/emulator/beam/erl_alloc_util.c +++ b/erts/emulator/beam/erl_alloc_util.c @@ -3489,7 +3489,9 @@ do_erts_alcu_alloc(ErtsAlcType_t type, void *extra, Uint size) fix = allctr->fix; if (fix) { int ix = type - ERTS_ALC_N_MIN_A_FIXED_SIZE; + ASSERT((unsigned)ix < ERTS_ALC_NO_FIXED_SIZES); ERTS_DBG_CHK_FIX_LIST(allctr, fix, ix, 1); + ASSERT(size <= fix[ix].type_size); fix[ix].used++; res = fix[ix].list; if (res) { @@ -3510,8 +3512,7 @@ do_erts_alcu_alloc(ErtsAlcType_t type, void *extra, Uint size) ERTS_DBG_CHK_FIX_LIST(allctr, fix, ix, 0); return res; } - if (size < 2*sizeof(UWord)) - size += sizeof(UWord); + size = fix[ix].type_size; if (fix[ix].limit < fix[ix].used) fix[ix].limit = fix[ix].used; if (fix[ix].max_used < fix[ix].used) @@ -4326,6 +4327,9 @@ erts_alcu_start(Allctr_t *allctr, AllctrInit_t *init) allctr->fix[i].list = NULL; allctr->fix[i].allocated = 0; allctr->fix[i].used = 0; +#ifdef ERTS_SMP + ASSERT(allctr->fix[i].type_size >= sizeof(ErtsAllctrFixDDBlock_t)); +#endif } } |