[PATCH] D31883: Don't assume PTHREAD_CREATE_JOINABLE is 0 on all systems

Aleksey Shlyapnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 11 10:44:58 PDT 2017


alekseyshl added inline comments.


================
Comment at: lib/lsan/lsan_interceptors.cc:61
+#endif
+
 INTERCEPTOR(void*, malloc, uptr size) {
----------------
fjricci wrote:
> alekseyshl wrote:
> > Why do we have to define them? why not use the proper definition in phtread.h?
> We don't want to include any system headers in this file.
Oh, we already have those defined in tsan... Let's move the definition to saniter_linux.h and sanitizer_mac.h, define them as enum (yes, I'd still vote for defining PTHREAD_CREATE_JOINABLE, I don't see the upside of not defining it) and reuse them in both tsan and lsan.


================
Comment at: lib/lsan/lsan_interceptors.cc:283
   AdjustStackSize(attr);
   int detached = 0;
   pthread_attr_getdetachstate(attr, &detached);
----------------
fjricci wrote:
> alekseyshl wrote:
> > int detached = PTHREAD_CREATE_JOINABLE; to be consistent with the rest of your change.
> This review established that we don't want to define PTHREAD_CREATE_JOINABLE (that value will get over-written by pthread_attr_getdetachstate anyway): D10606
pthread_attr_getdetachstate returns int and can fail, we're ignoring the error and go with a default value. I admit, it does not change the result of detached == PTHREAD_CREATE_DETACHED check, but does not feel like a sound practice.


https://reviews.llvm.org/D31883





More information about the llvm-commits mailing list