[libvirt] PATCH: 15/25: Prohibit non-threadsafe POSIX apis

Richard W.M. Jones rjones at redhat.com
Thu Jan 15 17:31:35 UTC 2009


On Tue, Jan 13, 2009 at 05:44:51PM +0000, Daniel P. Berrange wrote:
> There are a huge list of functions in POSIX which are not
> safe to use from multiple threads currently. I generated
> the list by looking at all libc symbol exports for variants
> which have a parallel _r symbol.
> 
>    nm -D --defined-only /lib/libc.so.6  \
>       | grep '_r$' \
>       | awk '{print $3}' \
>       | grep -v __ \
>       | grep -v qsort \
>       | grep -v readdir \
>       | sort \
>       | uniq \
>       | sed -e 's/_r//'
> 
> The qsort one is a red herring, since you only need qsort_r if
> you need to pass a extra 'void * opaque' data blob to your sort
> function - we don't, so don't need qsort_r.
> 
> The readdir one is also unneccessary, since reading from a single
> DIR* is safe from a single thread. readdir_r is also horrific
> 
> http://womble.decadentplace.org.uk/readdir_r-advisory.html
> 
> 
> This patch adds a 'make sc_prohibit_nonrentrant' rule to the
> 'syntax-check' for these forbidden functions.
> 
>  .x-sc_prohibit_nonreentrant |    8 ++++
>  Makefile.am                 |    2 +
>  Makefile.maint              |   11 +++++
>  Makefile.nonreentrant       |   85 ++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 106 insertions(+)

Yup, perfect, +1.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top




More information about the libvir-list mailing list