[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] [PATCH] daemon: don't access thread if pthread_creat

From: Dan Dedrick
Subject: Re: [libmicrohttpd] [PATCH] daemon: don't access thread if pthread_create failed
Date: Tue, 15 Mar 2016 15:47:57 -0400

Nevermind this is actually right I just got confused re-reading what this actually checks. I think the original patch is still reasonable.

On Tue, Mar 15, 2016 at 3:46 PM, Dan Dedrick <address@hidden> wrote:
Sorry I screwed up this patch. I need to swap this check. Please ignore.


On Tue, Mar 15, 2016 at 3:45 PM, Dan Dedrick <address@hidden> wrote:
If pthread_create fails for some reason we need to not access the
thread pointer as it will not be valid. Without this check a failed
return code from pthread_create would cause a SIGSEGV to occur.

An instance that pthread_create could fail is if enough connections were
established that we ran out of space in our mapping to create another
thread stack. Specifically I have seen this occur with
systemd-journal-gatewayd where there was a bug with not releasing
connections after they had disconnected. I submitted a fix for that
here: but it would really
be best if libmicrohttpd didn't SIGSEGV under these conditions.
 src/microhttpd/daemon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 1478604..e4d4e91 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -1283,7 +1283,8 @@ create_thread (MHD_thread_handle_ *thread,
   ret = pthread_create (thread, pattr,
                        start_routine, arg);
-  (void) pthread_setname_np (*thread, "libmicrohttpd");
+  if (0 == ret)
+    (void) pthread_setname_np (*thread, "libmicrohttpd");
   if (0 != daemon->thread_stack_size)
     pthread_attr_destroy (&attr);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]