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 a962b46080608acf8f20288f36ff6bab9537d11a..398990d19f214f7c78f18d09259270508740a944 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;
 }