Re: catching unitialized structures

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 






On Mon, Apr 29, 2013 at 7:53 PM, Emmanuel Dreyfus <manu@xxxxxxxxxx> wrote:
Vijay Bellur <vbellur@xxxxxxxxxx> wrote:

> There are a lot of places where we make an implicit assumption that
> GF_CALLOC and the likes memset the memory area to zero.

The problem I refer to is that on current Linux systems,
pthread_mutex_lock() will work on a zero'ed area where
pthread_mutex_init() was not called. That behavior should not be taken
for granted in the future on Linux, and it is likely to break on any non
Linux system.

Right. What Vijay said is that GF_CALLOC is the wrong place to initialize memory with magic values, as it is _expected_ to strictly zero-fill the allocated buffer just like calloc(). Detecting a missed pthread_mutex_init of a mutex within a calloc'ed structure requires a more complex technique.

Avati


[Index of Archives]     [Gluster Users]     [Ceph Users]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux