Hello Adriano,

If I understood correctly in this topic described same problem:

https://groups.google.com/g/firebird-support/c/oO9c_ppmfRg/m/-ukO9L37DQAJ

?

---
The problem with correct shutdown of module with shutdown function (or
component with "Dispose" method) is solved through counter of active calls.
Or counter of alive objects in case of OO-API.

I use this technology in my DLL servers.

Regards,
Dmitry Kovalenko

-----Original Message-----
From: Adriano dos Santos Fernandes [mailto:adrian...@gmail.com] 
Sent: Friday, January 21, 2022 10:08 PM
To: For discussion among Firebird Developers
<firebird-devel@lists.sourceforge.net>
Subject: Re: [Firebird-devel] MacOS problem with dlclose

Hi Alex and Paul!

I see three way to resolve this:

On 10/01/2022 16:19, Adriano dos Santos Fernandes wrote:
> Hi!
> 
> As reported in #7041, MacOS build (even in Intel) is returning errors 
> after some time (1 min) used:
> 
> Authentication error
> connection shutdown
> 
> I had debugged the problem, it happens when plugin manager tries to 
> unload plugins.
> 
> When it calls dlclose no error is returned but library is not really 
> unloaded.
> 
> Next time it loads the plugin again, it is already in memory and the 
> memory is not reinitialized nor constructors run again. Only the 
> plugin entry point is called.
> 
> That makes things unusable.
> 
> I have tracked why it is not unloading.
> 
> There is two reasons for it:
> 1) Usage of framework APIs / Objective-C
> 2) Usage of __thread variables
> 
> 1) https://developer.apple.com/forums/thread/122591
> 2) 
> https://github.com/rust-lang/rust/issues/28794#issuecomment-368693049
> 
> In our code (1) is happening with mac_utils.m and (2) due to 
> HAVE___THREAD being defined.
> 
> I have tested fixing (2) changing fb_tls.h define:
> 
> -#if defined(HAVE___THREAD)
> +#if defined(HAVE___THREAD) && !defined(DARWIN)
> 
> And reverting mac_utils changes it worked.
> 
> There is also suspicious code in
> src/yvalve/config/os/darwin/config_root.cpp but it has not needed to 
> be changed.
> 
> I have not deeply tested why this works in v3. It seems to not try to 
> unload plugins.
> 
> 
> Adriano



Firebird-Devel mailing list, web interface at
https://lists.sourceforge.net/lists/listinfo/firebird-devel



Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to