소스 검색

fix benign data race in pthread_attr_init

access to defaults should be protected against concurrent changes.
Rich Felker 6 년 전
부모
커밋
11ce1b133d
1개의 변경된 파일2개의 추가작업 그리고 0개의 파일을 삭제
  1. 2 0
      src/thread/pthread_attr_init.c

+ 2 - 0
src/thread/pthread_attr_init.c

@@ -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;
 }