Permalink
Browse files

Turn pause_and_exit() into pause_forever()

Summary:
pthread_exit can lead to confusing crashes for us: it raises
a "forced unwind", which it seems (strangely) will enter into C++
catch (...) blocks: but if you don't rethrow from one these blocks,
glibc will call abort() from a function called unwind_cleanup.  Our
LibEventWorker has a catch block of this sort that doesn't rethrow, so
calling pthread_exit below there will abort the program.  (The point
of this function is to just wait while another thread writes a
stacktrace file, so there's no reason to exit the thread.)
  • Loading branch information...
1 parent 7c67d64 commit a740eb09f19d9623efa5412a0aac3de541336dc5 @jdelong jdelong committed with joelpob Sep 21, 2012
Showing with 10 additions and 11 deletions.
  1. +7 −8 src/runtime/base/builtin_functions.cpp
  2. +3 −3 src/runtime/base/types.h
View
15 src/runtime/base/builtin_functions.cpp
@@ -1000,14 +1000,13 @@ Object create_object(CStrRef s, CArrRef params, bool init /* = true */,
}
}
-void pause_and_exit() {
- // NOTE: This is marked as __attribute__((noreturn)) in base/types.h
- // Signal sent, nothing can be trusted, don't do anything, as we might
- // write bad data, including calling exit handlers or destructors until the
- // signal handler (StackTrace) has had a chance to exit.
- sleep(300);
- // Should abort first, but it not try to exit
- pthread_exit(0);
+/*
+ * This function is used when another thread is segfaulting---we just
+ * want to wait forever to give it a chance to write a stacktrace file
+ * (and maybe a core file).
+ */
+void pause_forever() {
+ for (;;) sleep(300);
}
void check_request_surprise(ThreadInfo *info) {
View
6 src/runtime/base/types.h
@@ -397,21 +397,21 @@ inline void check_recursion(ThreadInfo *&info) {
}
// implemented in runtime/base/builtin_functions.cpp
-extern void pause_and_exit() ATTRIBUTE_COLD ATTRIBUTE_NORETURN;
+extern void pause_forever() ATTRIBUTE_COLD ATTRIBUTE_NORETURN;
extern void check_request_surprise(ThreadInfo *info) ATTRIBUTE_COLD;
extern bool SegFaulting;
inline void check_request_timeout(ThreadInfo *info) {
const_assert(!hhvm);
- if (SegFaulting) pause_and_exit();
+ if (SegFaulting) pause_forever();
info->m_mm->refreshStats();
if (info->m_reqInjectionData.conditionFlags) check_request_surprise(info);
}
inline void check_request_timeout_nomemcheck(ThreadInfo *info) {
const_assert(!hhvm);
- if (SegFaulting) pause_and_exit();
+ if (SegFaulting) pause_forever();
if (info->m_reqInjectionData.conditionFlags) check_request_surprise(info);
}

0 comments on commit a740eb0

Please sign in to comment.