Re: [openssl-dev] shlibloadtest failure on non-Linux

2017-05-09 Thread Matt Caswell


On 09/05/17 18:12, Nick Reilly wrote:
> 
> 
> On 2017-05-09 10:08 AM, Matt Caswell wrote:
>>
>> I'm not sure why this makes a difference. The return value of dlclose()
>> tells you whether there has been an error or not. Not whether the
>> library has actually been removed from address space. Or am I missing
>> your point?
> 
> dlclose() is returning an error and dlerror() reports that the library
> cannot be closed as it is still in use (from the leaked reference).

Hmmm. Arguably that is broken dlclose() behaviour. dlclose() is just
supposed to inform the system that a handle previously returned by
dlopen() is no longer required by the application. AFAIK there is no
requirement for all other handles returned from other dlopen() open
calls for the same shared library to be closed first (how would that
work anyway...unless there was a strict requirement for the handle
returned from the first call to dlopen() to always be the last one to be
used in a call to dlclose()?).

This is not a problem on other non-linux Unix based systems that we have
tried it on, so it looks to be something peculiar to QNX.

Does QNX have a "-znodelete" equivalent? That would be the most
preferable fix.

Another option might be something like this:

diff --git a/test/shlibloadtest.c b/test/shlibloadtest.c
index 6f220ba530..bc701b4333 100644
--- a/test/shlibloadtest.c
+++ b/test/shlibloadtest.c
@@ -65,8 +65,16 @@ static int shlib_sym(SHLIB lib, const char *symname,
SHLIB_SYM *sym)

 static int shlib_close(SHLIB lib)
 {
+#ifdefined OPENSSL_SYS_QNX
+/*
+ * Ignore errors from dlclose() on QNX to avoid spurious complaints
about
+ * being unable to close it due to it still being in use.
+ */
+dlclose(lib);
+#else
 if (dlclose(lib) != 0)
 return 0;
+#endif

 return 1;
 }

Matt

-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] shlibloadtest failure on non-Linux

2017-05-09 Thread Salz, Rich via openssl-dev
> Sense of OPENSSL_USE_NODELETE has been reversed i.e. you want #ifdef
> and not #ifndef

Argh, you're right.
 
> Also I think its still fair game to try a dlclose() just that the
> dlclose() may return an error if OPENSSL_USE_NODELETE is not defined.

I'll just leave it as-is.  Thanks for looking at this!
-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] shlibloadtest failure on non-Linux

2017-05-09 Thread Nick Reilly



On 2017-05-09 10:03 AM, Salz, Rich via openssl-dev wrote:

doesn't test for whether this is set. I think the shlibloadtest should only test
the dlclose() return value on if OPENSSL_USE_NODELETE is set.


Please see https://github.com/openssl/openssl/pull/3399



Sense of OPENSSL_USE_NODELETE has been reversed i.e. you want #ifdef and 
not #ifndef


Also I think its still fair game to try a dlclose() just that the 
dlclose() may return an error if OPENSSL_USE_NODELETE is not defined.


Regards,
Nick.
--
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] shlibloadtest failure on non-Linux

2017-05-09 Thread Nick Reilly



On 2017-05-09 10:08 AM, Matt Caswell wrote:


I'm not sure why this makes a difference. The return value of dlclose()
tells you whether there has been an error or not. Not whether the
library has actually been removed from address space. Or am I missing
your point?


dlclose() is returning an error and dlerror() reports that the library 
cannot be closed as it is still in use (from the leaked reference).



No. The whole point of OPENSSL_USE_NODELETE is to indicate that the
library won't be unloaded until process exit because we've ensured that
through some other mechanism (e.g. because we built it using
"-znodelete" on Linux). We do not rely on the linux specific behaviour.
If your platform doesn't have some other mechanism then you need to use
the default "deliberate leak" approach.


Ok, misunderstood the intention of OPENSSL_USE_NODELETE, didn't realise 
it meant -znodelete.


Thanks,
Nick.
--
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] shlibloadtest failure on non-Linux

2017-05-09 Thread Matt Caswell


On 09/05/17 15:03, Salz, Rich via openssl-dev wrote:
>> doesn't test for whether this is set. I think the shlibloadtest should only 
>> test
>> the dlclose() return value on if OPENSSL_USE_NODELETE is set.
> 
> Please see https://github.com/openssl/openssl/pull/3399
>  
>> 2) crypto/init.c at line 77 does "atexit(OPENSSL_cleanup)". If I try defining
>> OPENSSL_USE_NODELETE then this atexit() handler is meant to cleanup on
>> unload of the shared library, but this meaning of atexit() is Linux 
>> specific. It is
>> not required in POSIX and the Linux manpage lists this usage under the
>> "Linux notes" section.
> 
> Does changing the guard to this work?
> #if !defined(OPENSSL_SYS_UEFI) &&  !defined(OPENSSL_SYS_QNX)
> 

That presumably would mean that the library would not clean up at all on
QNX, which is probably undesirable.

Matt
-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev


Re: [openssl-dev] shlibloadtest failure on non-Linux

2017-05-09 Thread Salz, Rich via openssl-dev
> doesn't test for whether this is set. I think the shlibloadtest should only 
> test
> the dlclose() return value on if OPENSSL_USE_NODELETE is set.

Please see https://github.com/openssl/openssl/pull/3399
 
> 2) crypto/init.c at line 77 does "atexit(OPENSSL_cleanup)". If I try defining
> OPENSSL_USE_NODELETE then this atexit() handler is meant to cleanup on
> unload of the shared library, but this meaning of atexit() is Linux specific. 
> It is
> not required in POSIX and the Linux manpage lists this usage under the
> "Linux notes" section.

Does changing the guard to this work?
#if !defined(OPENSSL_SYS_UEFI) &&  !defined(OPENSSL_SYS_QNX)

-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev