Hi Alex and Paul!

I see three way to resolve this:

1) Disable unload timer in PluginManager in MacOS.

2) Makes it possible for engine plugin to relive when it was shut down
and its entry point is called again. I have tested this solution and it
seems to work, but some details must be more tested, like
shutdown/relive of trace's ConfigStorage. In any case, with active
sandbox code it will never really unload the libraries, just the plugins.

3) Disable things related to sandbox
(https://paulbeachsblog.blogspot.com/2021/01/firebird-embedded-in-sandboxed-macos-app.html)

I think 1 is the way to go.

Opinions?


Adriano


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

Reply via email to