OSDN Git Service

fix benign data race in pthread_attr_init
authorRich Felker <dalias@aerifal.cx>
Tue, 18 Sep 2018 23:41:03 +0000 (19:41 -0400)
committerRich Felker <dalias@aerifal.cx>
Tue, 18 Sep 2018 23:41:03 +0000 (19:41 -0400)
access to defaults should be protected against concurrent changes.

src/thread/pthread_attr_init.c

index a962b46..398990d 100644 (file)
@@ -6,7 +6,9 @@ extern size_t __default_guardsize;
 int pthread_attr_init(pthread_attr_t *a)
 {
        *a = (pthread_attr_t){0};
+       __acquire_ptc();
        a->_a_stacksize = __default_stacksize;
        a->_a_guardsize = __default_guardsize;
+       __release_ptc();
        return 0;
 }