[PATCH] Don't consider it a hard error if we fail to limit the pthread stack size.
Thomas Schwinge
thomas at codesourcery.com
Mon Mar 25 09:05:18 PDT 2013
The GNU Hurd's libpthread (currently) cannot support arbitrary stack size
limits, and as the stack size specified by pthread_attr_setstacksize is only
advisory anyway, ignore failure to set it.
---
lib/Support/Threading.cpp | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git lib/Support/Threading.cpp lib/Support/Threading.cpp
index 13fba2e..3b9eb73 100644
--- lib/Support/Threading.cpp
+++ lib/Support/Threading.cpp
@@ -66,6 +66,10 @@ void llvm::llvm_release_global_lock() {
#if LLVM_ENABLE_THREADS != 0 && defined(HAVE_PTHREAD_H)
#include <pthread.h>
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/Errno.h"
+#include "llvm/Support/raw_ostream.h"
+
struct ThreadInfo {
void (*UserFn)(void *);
void *UserData;
@@ -86,10 +90,15 @@ void llvm::llvm_execute_on_thread(void (*Fn)(void*), void *UserData,
if (::pthread_attr_init(&Attr) != 0)
return;
- // Set the requested stack size, if given.
+ // Try to set the requested stack size, if given. As this is only advisory
+ // (sets the *minimum* size), if this safety measure fails, we'll proceed
+ // anyway, hoping for the best instead of erroring out.
if (RequestedStackSize != 0) {
- if (::pthread_attr_setstacksize(&Attr, RequestedStackSize) != 0)
- goto error;
+ int Err = ::pthread_attr_setstacksize(&Attr, RequestedStackSize);
+ if (Err != 0)
+ DEBUG(errs() << "pthread_attr_setstacksize(size_t = "
+ << RequestedStackSize << ") failed: " << llvm::sys::StrError(Err)
+ << "\n");
}
// Construct and execute the thread.
--
1.7.9.5
More information about the llvm-commits
mailing list