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

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



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.

  Cool, good idea ! +1

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/


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