You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2017/02/06 21:01:10 UTC
svn commit: r1781952 - in /tomcat/native/trunk/native: include/ssl_private.h
src/ssl.c
Author: markt
Date: Mon Feb 6 21:01:09 2017
New Revision: 1781952
URL: http://svn.apache.org/viewvc?rev=1781952&view=rev
Log:
Follow-up to r1781943
Fix build errors on Windows
Confirmed that terminated threads are removed from the hash
Modified:
tomcat/native/trunk/native/include/ssl_private.h
tomcat/native/trunk/native/src/ssl.c
Modified: tomcat/native/trunk/native/include/ssl_private.h
URL: http://svn.apache.org/viewvc/tomcat/native/trunk/native/include/ssl_private.h?rev=1781952&r1=1781951&r2=1781952&view=diff
==============================================================================
--- tomcat/native/trunk/native/include/ssl_private.h (original)
+++ tomcat/native/trunk/native/include/ssl_private.h Mon Feb 6 21:01:09 2017
@@ -364,7 +364,7 @@ int SSL_callback_alpn_select_pro
void SSL_thread_exit(void);
-#if (OPENSSL_VERSION_NUMBER < 0x10100000L) && ! defined(WIN32)
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L) && ! (defined(WIN32) || defined(WIN64))
unsigned long SSL_ERR_get(void);
void SSL_ERR_clear(void);
#else
Modified: tomcat/native/trunk/native/src/ssl.c
URL: http://svn.apache.org/viewvc/tomcat/native/trunk/native/src/ssl.c?rev=1781952&r1=1781951&r2=1781952&view=diff
==============================================================================
--- tomcat/native/trunk/native/src/ssl.c (original)
+++ tomcat/native/trunk/native/src/ssl.c Mon Feb 6 21:01:09 2017
@@ -445,6 +445,7 @@ void SSL_thread_exit(void) {
}
#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if ! (defined(WIN32) || defined(WIN64))
unsigned long SSL_ERR_get() {
apr_threadkey_private_set(thread_exit_key, thread_exit_key);
return ERR_get_error();
@@ -454,6 +455,7 @@ void SSL_ERR_clear() {
apr_threadkey_private_set(thread_exit_key, thread_exit_key);
ERR_clear_error();
}
+#endif
static void _ssl_thread_exit(void *data) {
UNREFERENCED(data);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1781952 - in /tomcat/native/trunk/native:
include/ssl_private.h src/ssl.c
Posted by th...@gmail.com.
On Mon, Feb 6, 2017 at 6:08 PM, Mark Thomas <ma...@apache.org> wrote:
> On 06/02/17 22:55, Mark Thomas wrote:
>>
>> On 06/02/17 21:20, therealneworld@gmail.com wrote:
>>>
>>> Mark,
>>>
>>> If there is anything I can do to help work on the patch I will,
>>> however as I mentioned in the bug I don't have a windows environment
>>> so I am basically useless if that is where the issues exist.
>>
>>
>> Yes, this is Windows.
>>
>> The problem with the original approach was that DLL_THREAD_DETACH was
>> being called for all threads - including JVM threads stopping after the
>> native library had effectively closed down. Hence the crash.
>>
>> I'm currently trying to use the same approach as used for Linux but I'm
>> not seeing the thread local being destroyed when the associated thread
>> exits. I'm still debugging why.
>>
>> Any hints, suggestions etc. welcome.
>
>
> Looking at the APR docs and source, the destructor function is only called
> when apr_threadkey_private_delete is called and I don't see that being
> called anywhere. How is this working on Linux? I suspect it isn't but I
> haven't set up a build env to confirm that at this point.
>
Looking at the apr source threadproc/win32/threadpriv.c the destructor
is actually thrown away on windows, so that approach will not work on
windows. I think what you are looking at is the TlsAlloc in create and
the TlsFree in delete, which I don't think relates to the value stored
but the key structure itself.
-nate
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1781952 - in /tomcat/native/trunk/native:
include/ssl_private.h src/ssl.c
Posted by Mark Thomas <ma...@apache.org>.
On 07/02/17 08:59, Mark Thomas wrote:
> On 06/02/17 23:55, therealneworld@gmail.com wrote:
>> On Mon, Feb 6, 2017 at 6:08 PM, Mark Thomas <ma...@apache.org> wrote:
>>> On 06/02/17 22:55, Mark Thomas wrote:
>>>>
>>>> On 06/02/17 21:20, therealneworld@gmail.com wrote:
>>>>>
>>>>> Mark,
>>>>>
>>>>> If there is anything I can do to help work on the patch I will,
>>>>> however as I mentioned in the bug I don't have a windows environment
>>>>> so I am basically useless if that is where the issues exist.
>>>>
>>>>
>>>> Yes, this is Windows.
>>>>
>>>> The problem with the original approach was that DLL_THREAD_DETACH was
>>>> being called for all threads - including JVM threads stopping after the
>>>> native library had effectively closed down. Hence the crash.
>>>>
>>>> I'm currently trying to use the same approach as used for Linux but I'm
>>>> not seeing the thread local being destroyed when the associated thread
>>>> exits. I'm still debugging why.
>>>>
>>>> Any hints, suggestions etc. welcome.
>>>
>>>
>>> Looking at the APR docs and source, the destructor function is only
>>> called
>>> when apr_threadkey_private_delete is called and I don't see that being
>>> called anywhere. How is this working on Linux? I suspect it isn't but I
>>> haven't set up a build env to confirm that at this point.
>>>
>>
>> It should work on linux because pthreads guarantees that the
>> destructor will be called on thread exit if the value is not NULL. In
>> fact if you call pthread_key_delete the destructor is explicitly not
>> called and it is up to the caller to handle any clean up. I used
>> openssl's approach which obviously does not use apr but uses pthreads
>> directly and did a rough mapping on apr's approach to thread locals.
>> WIndows does not have the concept of a destructor for their normal
>> thread locals so that is why openssl used the thread detatch mechanism
>> and I did too. I do know that if you use windows fibers instead of
>> threads there is destructor but I didn't think that was an option with
>> how tomcat native was being used but I am not an expert.
>
> Thanks for the explanation.
>
> We don't have any control over the native implementation of these
> threads as they are all JVM created.
>
> I'll go back to looking at if I can find a way to get the
> DLL_THREAD_DETACH approach to work without crashing.
Should be fixed now.
Thanks again for the help.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1781952 - in /tomcat/native/trunk/native:
include/ssl_private.h src/ssl.c
Posted by Mark Thomas <ma...@apache.org>.
On 06/02/17 23:55, therealneworld@gmail.com wrote:
> On Mon, Feb 6, 2017 at 6:08 PM, Mark Thomas <ma...@apache.org> wrote:
>> On 06/02/17 22:55, Mark Thomas wrote:
>>>
>>> On 06/02/17 21:20, therealneworld@gmail.com wrote:
>>>>
>>>> Mark,
>>>>
>>>> If there is anything I can do to help work on the patch I will,
>>>> however as I mentioned in the bug I don't have a windows environment
>>>> so I am basically useless if that is where the issues exist.
>>>
>>>
>>> Yes, this is Windows.
>>>
>>> The problem with the original approach was that DLL_THREAD_DETACH was
>>> being called for all threads - including JVM threads stopping after the
>>> native library had effectively closed down. Hence the crash.
>>>
>>> I'm currently trying to use the same approach as used for Linux but I'm
>>> not seeing the thread local being destroyed when the associated thread
>>> exits. I'm still debugging why.
>>>
>>> Any hints, suggestions etc. welcome.
>>
>>
>> Looking at the APR docs and source, the destructor function is only called
>> when apr_threadkey_private_delete is called and I don't see that being
>> called anywhere. How is this working on Linux? I suspect it isn't but I
>> haven't set up a build env to confirm that at this point.
>>
>
> It should work on linux because pthreads guarantees that the
> destructor will be called on thread exit if the value is not NULL. In
> fact if you call pthread_key_delete the destructor is explicitly not
> called and it is up to the caller to handle any clean up. I used
> openssl's approach which obviously does not use apr but uses pthreads
> directly and did a rough mapping on apr's approach to thread locals.
> WIndows does not have the concept of a destructor for their normal
> thread locals so that is why openssl used the thread detatch mechanism
> and I did too. I do know that if you use windows fibers instead of
> threads there is destructor but I didn't think that was an option with
> how tomcat native was being used but I am not an expert.
Thanks for the explanation.
We don't have any control over the native implementation of these
threads as they are all JVM created.
I'll go back to looking at if I can find a way to get the
DLL_THREAD_DETACH approach to work without crashing.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1781952 - in /tomcat/native/trunk/native:
include/ssl_private.h src/ssl.c
Posted by th...@gmail.com.
On Mon, Feb 6, 2017 at 6:08 PM, Mark Thomas <ma...@apache.org> wrote:
> On 06/02/17 22:55, Mark Thomas wrote:
>>
>> On 06/02/17 21:20, therealneworld@gmail.com wrote:
>>>
>>> Mark,
>>>
>>> If there is anything I can do to help work on the patch I will,
>>> however as I mentioned in the bug I don't have a windows environment
>>> so I am basically useless if that is where the issues exist.
>>
>>
>> Yes, this is Windows.
>>
>> The problem with the original approach was that DLL_THREAD_DETACH was
>> being called for all threads - including JVM threads stopping after the
>> native library had effectively closed down. Hence the crash.
>>
>> I'm currently trying to use the same approach as used for Linux but I'm
>> not seeing the thread local being destroyed when the associated thread
>> exits. I'm still debugging why.
>>
>> Any hints, suggestions etc. welcome.
>
>
> Looking at the APR docs and source, the destructor function is only called
> when apr_threadkey_private_delete is called and I don't see that being
> called anywhere. How is this working on Linux? I suspect it isn't but I
> haven't set up a build env to confirm that at this point.
>
It should work on linux because pthreads guarantees that the
destructor will be called on thread exit if the value is not NULL. In
fact if you call pthread_key_delete the destructor is explicitly not
called and it is up to the caller to handle any clean up. I used
openssl's approach which obviously does not use apr but uses pthreads
directly and did a rough mapping on apr's approach to thread locals.
WIndows does not have the concept of a destructor for their normal
thread locals so that is why openssl used the thread detatch mechanism
and I did too. I do know that if you use windows fibers instead of
threads there is destructor but I didn't think that was an option with
how tomcat native was being used but I am not an expert.
-nate
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1781952 - in /tomcat/native/trunk/native:
include/ssl_private.h src/ssl.c
Posted by Mark Thomas <ma...@apache.org>.
On 06/02/17 22:55, Mark Thomas wrote:
> On 06/02/17 21:20, therealneworld@gmail.com wrote:
>> Mark,
>>
>> If there is anything I can do to help work on the patch I will,
>> however as I mentioned in the bug I don't have a windows environment
>> so I am basically useless if that is where the issues exist.
>
> Yes, this is Windows.
>
> The problem with the original approach was that DLL_THREAD_DETACH was
> being called for all threads - including JVM threads stopping after the
> native library had effectively closed down. Hence the crash.
>
> I'm currently trying to use the same approach as used for Linux but I'm
> not seeing the thread local being destroyed when the associated thread
> exits. I'm still debugging why.
>
> Any hints, suggestions etc. welcome.
Looking at the APR docs and source, the destructor function is only
called when apr_threadkey_private_delete is called and I don't see that
being called anywhere. How is this working on Linux? I suspect it isn't
but I haven't set up a build env to confirm that at this point.
Mark
>
> Mark
>
>>
>> -nate
>>
>> On Mon, Feb 6, 2017 at 4:03 PM, Mark Thomas <ma...@apache.org> wrote:
>>> On 06/02/17 21:01, markt@apache.org wrote:
>>>>
>>>> Author: markt
>>>> Date: Mon Feb 6 21:01:09 2017
>>>> New Revision: 1781952
>>>>
>>>> URL: http://svn.apache.org/viewvc?rev=1781952&view=rev
>>>> Log:
>>>> Follow-up to r1781943
>>>> Fix build errors on Windows
>>>> Confirmed that terminated threads are removed from the hash
>>>
>>>
>>> The patch isn't quite there yet. It triggers a JVM crash on shutdown
>>> that
>>> I'm currently looking at.
>>>
>>> Mark
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1781952 - in /tomcat/native/trunk/native:
include/ssl_private.h src/ssl.c
Posted by Mark Thomas <ma...@apache.org>.
On 06/02/17 21:20, therealneworld@gmail.com wrote:
> Mark,
>
> If there is anything I can do to help work on the patch I will,
> however as I mentioned in the bug I don't have a windows environment
> so I am basically useless if that is where the issues exist.
Yes, this is Windows.
The problem with the original approach was that DLL_THREAD_DETACH was
being called for all threads - including JVM threads stopping after the
native library had effectively closed down. Hence the crash.
I'm currently trying to use the same approach as used for Linux but I'm
not seeing the thread local being destroyed when the associated thread
exits. I'm still debugging why.
Any hints, suggestions etc. welcome.
Mark
>
> -nate
>
> On Mon, Feb 6, 2017 at 4:03 PM, Mark Thomas <ma...@apache.org> wrote:
>> On 06/02/17 21:01, markt@apache.org wrote:
>>>
>>> Author: markt
>>> Date: Mon Feb 6 21:01:09 2017
>>> New Revision: 1781952
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1781952&view=rev
>>> Log:
>>> Follow-up to r1781943
>>> Fix build errors on Windows
>>> Confirmed that terminated threads are removed from the hash
>>
>>
>> The patch isn't quite there yet. It triggers a JVM crash on shutdown that
>> I'm currently looking at.
>>
>> Mark
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1781952 - in /tomcat/native/trunk/native:
include/ssl_private.h src/ssl.c
Posted by th...@gmail.com.
Mark,
If there is anything I can do to help work on the patch I will,
however as I mentioned in the bug I don't have a windows environment
so I am basically useless if that is where the issues exist.
-nate
On Mon, Feb 6, 2017 at 4:03 PM, Mark Thomas <ma...@apache.org> wrote:
> On 06/02/17 21:01, markt@apache.org wrote:
>>
>> Author: markt
>> Date: Mon Feb 6 21:01:09 2017
>> New Revision: 1781952
>>
>> URL: http://svn.apache.org/viewvc?rev=1781952&view=rev
>> Log:
>> Follow-up to r1781943
>> Fix build errors on Windows
>> Confirmed that terminated threads are removed from the hash
>
>
> The patch isn't quite there yet. It triggers a JVM crash on shutdown that
> I'm currently looking at.
>
> Mark
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1781952 - in /tomcat/native/trunk/native:
include/ssl_private.h src/ssl.c
Posted by Mark Thomas <ma...@apache.org>.
On 06/02/17 21:01, markt@apache.org wrote:
> Author: markt
> Date: Mon Feb 6 21:01:09 2017
> New Revision: 1781952
>
> URL: http://svn.apache.org/viewvc?rev=1781952&view=rev
> Log:
> Follow-up to r1781943
> Fix build errors on Windows
> Confirmed that terminated threads are removed from the hash
The patch isn't quite there yet. It triggers a JVM crash on shutdown
that I'm currently looking at.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org