httpd-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 42728] New: - mod_ssl thread detaching not releasing handles
Date Sun, 24 Jun 2007 01:00:05 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42728>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42728

           Summary: mod_ssl thread detaching not releasing handles
           Product: Apache httpd-2
           Version: 2.2.4
          Platform: PC
        OS/Version: Windows Server 2003
            Status: NEW
          Severity: normal
          Priority: P2
         Component: mod_ssl
        AssignedTo: bugs@httpd.apache.org
        ReportedBy: beau.croteau@ca.com


the mod_ssl module has the following code implmented:
static unsigned long ssl_util_thr_id(void)
{
    /* OpenSSL needs this to return an unsigned long.  On OS/390, the pthread
     * id is a structure twice that big.  Use the TCB pointer instead as a
     * unique unsigned long.
     */
#ifdef __MVS__
    struct PSA {
        char unmapped[540];
        unsigned long PSATOLD;
    } *psaptr = 0;

    return psaptr->PSATOLD;
#else
    return (unsigned long) apr_os_thread_current();
#endif
}

And when the following code is called inside of openssl 0.9.8e:
	case DLL_THREAD_DETACH:
		ERR_remove_state(0);
		break;

This causes the CRYPTO_set_id_callback() to be called.  The problem is that
apr_os_thread_current() calls DuplicateHandle for the thread and this causes the
thread HANDLE to leak for the detaching thread.

This can be reproduced by having an apache module that that does the following
with the mod_ssl module loaded:
static void* APR_THREAD_FUNC testThread2(apr_thread_t *thd,void* input)
{
	printf("Sample module: Another thread being launching -
%d\n",GetCurrentThreadId());
	apr_thread_exit(thd,APR_SUCCESS);
	return NULL;
}

static void* APR_THREAD_FUNC testThread(apr_thread_t *thd,void* input)
{
	apr_thread_t *thd_arr;
	apr_pool_t *mp;
	apr_threadattr_t *thd_attr;
	
	apr_pool_create(&mp, NULL);
	apr_threadattr_create (&thd_attr, mp);
	apr_threadattr_detach_set (thd_attr, 1);

	while(1)
	{
		printf("Sample module, launching thread.\n");
		//_beginthread(testThread2,0,NULL);
		apr_thread_create(&thd_arr, thd_attr, testThread2, NULL, mp);
		Sleep(5000);
	}
	apr_thread_exit(thd,APR_SUCCESS);
	return NULL;
}
static int helloworld_handler(request_rec *r) {
	apr_thread_t *thd_arr;
	apr_pool_t *mp;
	apr_threadattr_t *thd_attr;

  /* First, some housekeeping. */
  if (!r->handler || strcasecmp(r->handler, "helloworld") != 0) {
    /* r->handler wasn't "helloworld", so it's none of our business */
    return DECLINED;
  }

  if (r->method_number != M_GET) {
    /* We only accept GET and HEAD requests.
     * They are identical for the purposes of a content generator
     * Returning an HTTP error code causes Apache to return an
     * error page (ErrorDocument) to the client.
     */
    return HTTP_METHOD_NOT_ALLOWED;
  }

	/* OK, we're happy with this request, so we'll return the response. */

	ap_set_content_type(r, "text/html");
	ap_rputs("<title>Hello World!</title> .... etc...starting threads...", r);

	apr_pool_create(&mp, NULL);
	apr_threadattr_create (&thd_attr, mp);
	apr_threadattr_detach_set (thd_attr, 1);
	apr_thread_create(&thd_arr, thd_attr, testThread, NULL, mp);


  /* we return OK to indicate that we have successfully processed
   * the request.  No further processing is required.
   */
  return OK;
}

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


Mime
View raw message