Make sure that there are no more than 256 size clases, since size2bin can only

encode bin indices in [0..255].
This commit is contained in:
Jason Evans 2009-11-12 17:57:57 -08:00
parent 1517cc6df7
commit 87704ea339

View File

@ -5294,6 +5294,17 @@ MALLOC_OUT:
ncbins = ((cspace_max - cspace_min) >> CACHELINE_2POW) + 1;
nsbins = ((sspace_max - sspace_min) >> SUBPAGE_2POW) + 1;
nbins = ntbins + nqbins + ncbins + nsbins;
/*
* The size2bin lookup table uses uint8_t to encode each bin index, so
* we cannot support more than 256 size classes (not a problem in
* practice).
*/
if (nbins > 256) {
char line_buf[UMAX2S_BUFSIZE];
jemalloc_message("<jemalloc>: Too many size classes (",
umax2s(nbins, line_buf), " > 256)\n", "");
abort();
}
if (size2bin_init()) {
malloc_mutex_unlock(&init_lock);