svn commit: r328218 - in head/sys: amd64/amd64 arm/xscale/ixp425 arm64/arm64 cam cam/ctl compat/ndis dev/aacraid dev/advansys dev/ath dev/beri/virtio dev/bnxt dev/bwn dev/ciss dev/cxgbe/crypto dev/...

Conrad Meyer cem at freebsd.org
Wed Jan 24 18:48:52 UTC 2018


On Wed, Jan 24, 2018 at 10:40 AM, Hans Petter Selasky <hps at selasky.org> wrote:
> On 01/24/18 19:28, Warner Losh wrote:
>>
>> Does mallocarray(10 ,1Gb) panic on i386? It does not. It should.
>
>
> Hi,
>
> If M_WAITOK is specified, then sleep forever and print a message.
> Else return NULL ?

Depends on the machine.  From malloc.9:

> If the multiplication of nmemb and size would cause an integer overflow, the mallocarray() function induces a panic.

64-bit arch does not experience overflow and will sleep until 10GB is
available.  (This is why the caller should do a narrower check.)

32-bit panics, since 10 * 1GB overflows 32-bit size_t (== u_long).

Best,
Conrad


More information about the svn-src-head mailing list