FirebirdSQL / NETProvider

Firebird ADO.NET Data Provider
https://www.firebirdsql.org/en/net-provider/
Other
152 stars 63 forks source link

.NET provider should explicitly call fb_shutdown() on application exit when using Firebird Embedded [DNET806] #743

Closed firebird-automations closed 5 years ago

firebird-automations commented 6 years ago

Submitted by: @mrotteveel

Is related to DNET802

If the apllication exits and there are still connections open using Firebird Embedded, then the exit may produce an access violation (0xc0000005 error). The root cause is that the fbembed.dll/fbclient.dll will call fb_shutdown() itself, but one of the other libraries (eg fbintl.dll) may already have been unloaded.

To prevent this, on exit the .NET provider should explicitly call fb_shutdown for any of the native libries loaded (but especially for embedded).

See also "Crash Firebird 2.5.8 Embedded with Firebird http://Ado.net provider." on Firebird-devel.

Related: DNET802 (cleaning up the connection pool on exit will also prevent the access violation).

Commits: FirebirdSQL/NETProvider@469bbac8e8058ef9f09474fda6a801ac28d2a806

firebird-automations commented 6 years ago

Commented by: @cincuranet

I suppose the DNET802 will cover that fully, no?

firebird-automations commented 6 years ago

Commented by: @mrotteveel

Maybe, but what I get from the reaction of Vlad is that it would be better to call fb_shutdown explicitly always when the native library has been loaded.

firebird-automations commented 5 years ago
Modified by: @cincuranet Link: This issue is related to [DNET802](https://github.com/FirebirdSQL/NETProvider/issues?q=DNET802+in%3Atitle) \[ [DNET802](https://github.com/FirebirdSQL/NETProvider/issues?q=DNET802+in%3Atitle) \]
firebird-automations commented 5 years ago
Modified by: @cincuranet Fix Version: 6\.5\.0\.0 \[ 10887 \]
firebird-automations commented 5 years ago
Modified by: @cincuranet status: Open \[ 1 \] =\> Resolved \[ 5 \] resolution: Fixed \[ 1 \]
firebird-automations commented 5 years ago

Commented by: fish (fishcodelib)

{ ShutdownHelper.RegisterFbClientShutdown(() => result.fb_shutdown(0, 0)); //This will throw the following error when connecting to Firebird 2.1 and earlier. }

System.EntryPointNotFoundException HResult=0x80131523 Message=Unable to find an entry point named 'fb_shutdown' in DLL 'J:\fbembed.dll'. Source=FB_431220871_Assembly StackTrace: at FB_431220871_Class.fb_shutdown(Int32 timeout, Int32 reason) at FB_431220871_Class.IFbClient.fb_shutdown(Int32 timeout, Int32 reason)

firebird-automations commented 5 years ago

Commented by: @cincuranet

Yeah I know. Given the 2.1 is not supported by CORE either, I'd like to not bury myself with too much compatibility. Previous versions are still here and working. Yet it doesn't seem to be right, just because of this. Probably just wrapping in in try-catch and ignoring the EntryPointNotFoundException is good enough solution.