mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-22 04:50:07 +00:00
Fix race in qsort_r initialization.
This commit is contained in:
parent
42acbb92c8
commit
fb88ac72c2
@ -1,3 +1,9 @@
|
||||
2010-12-09 Ulrich Drepper <drepper@gmail.com>
|
||||
|
||||
[BZ #11655]
|
||||
* stdlib/msort.c (qsort_r): Make sure both phys_pages and pagesize
|
||||
are initialized.
|
||||
|
||||
2010-12-09 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* string/bits/string3.h (memmove, bcopy): Remove __restrict.
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <memcopy.h>
|
||||
#include <errno.h>
|
||||
#include <atomic.h>
|
||||
|
||||
struct msort_param
|
||||
{
|
||||
@ -182,7 +183,7 @@ qsort_r (void *b, size_t n, size_t s, __compar_d_fn_t cmp, void *arg)
|
||||
static long int phys_pages;
|
||||
static int pagesize;
|
||||
|
||||
if (phys_pages == 0)
|
||||
if (pagesize == 0)
|
||||
{
|
||||
phys_pages = __sysconf (_SC_PHYS_PAGES);
|
||||
|
||||
@ -197,6 +198,9 @@ qsort_r (void *b, size_t n, size_t s, __compar_d_fn_t cmp, void *arg)
|
||||
a quarter of the physical memory. */
|
||||
phys_pages /= 4;
|
||||
|
||||
/* Make sure phys_pages is written to memory. */
|
||||
atomic_write_barrier ();
|
||||
|
||||
pagesize = __sysconf (_SC_PAGESIZE);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user