Re: Questioning the overflow check in jemalloc

2017-09-07 Thread Joerg Sonnenberger
On Thu, Sep 07, 2017 at 03:56:15PM +0200, Pierre Pronchery wrote: > In the first case SIZE_T_MAX is shifted left by 16 bits and in the second > case 32, as intended. But then why is there a cast to unsigned long long at > all? The left operand of that binary AND (&) is a size_t anyway, and will > n

Questioning the overflow check in jemalloc

2017-09-07 Thread Pierre Pronchery
Hi tech-userlevel@, I just had a look at the implementation of calloc() in NetBSD's libc, which seems to be from jemalloc actually. Its check for integer overflows is as follows, in src/lib/libc/stdlib/jemalloc.c: 3857 /* 3858 * Try to avoid division