Re: [Firebird-devel] Crash Firebird 2.5.8 Embedded with Firebird Ado.net provider.

2018-02-07 Thread Mark Rotteveel

On 7-2-2018 12:36, Vlad Khorsun via Firebird-devel wrote:

07.02.2018 13:26, Mark Rotteveel wrote:

On 7-2-2018 11:55, Mark Rotteveel wrote:
Shouldn't the engine be able to cope with this?


   Yes, and fb_shutdown handle it. But it can't handle it correctly when 
process

exits and Windows already unloaded some dlls and kill all other threads.


That seems at odds with the documentation. To quote from README.fb_shutdown:

"""
Normally it should not be used, because Firebird libraries (both kinds - 
embedded or pure client) do call it automatically at exit(). To make 
fb_shutdown() be called at exit, you should attach at least one database 
(or service).

"""

This wording to me suggests the client/embedded should be able to handle 
this correctly without the application calling fb_shutdown() explicitly.


Mark
--
Mark Rotteveel

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] Crash Firebird 2.5.8 Embedded with Firebird Ado.net provider.

2018-02-07 Thread Vlad Khorsun via Firebird-devel

07.02.2018 14:17, Mark Rotteveel пишет:

On 7-2-2018 12:36, Vlad Khorsun via Firebird-devel wrote:

07.02.2018 13:26, Mark Rotteveel wrote:

On 7-2-2018 11:55, Mark Rotteveel wrote:
Someone reported a crash on shutdown of Firebird 2.5.8 Embedded in a C# application on stack overflow: 
https://stackoverflow.com/questions/48644878/appcrash-in-fbintl-dll-if-using-embedded-mode-in-my-c-app.


I can reproduce it with the provided example application.

I tried to reproduce this by recreating the example using Jaybird, but there it works OK. Does anyone have an idea what the 
cause might be, and if this would be something in Firebird Embedded itself, or with the ADO.net provider?


I found the cause, the connection pool was active in Firebird ADO.net, and the connections weren't closed at the time the engine 
was unloaded.


Shouldn't the engine be able to cope with this?


   Yes, and fb_shutdown handle it. But it can't handle it correctly when process
exits and Windows already unloaded some dlls and kill all other threads.


But what causes the observed difference between the example table that only has an integer id column (and doesn't trigger the AV), 
and the one that also has a varchar column and an expression index (lower(title))?


  Varchar column and string function (lower) usage means that intl library 
could be loaded and
used by the engine. Later, when process exits without explicit call of 
fb_shutdown with open
connection to the database, there could be a case when fbintl.dll is already 
unloaded by the
OS while fb_shutdown tries to correctly free resources (and call something in 
fbintl.dll).

  Note, the order of unload of DLL's by the OS is not defined.

Regards,
Vlad

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] Crash Firebird 2.5.8 Embedded with Firebird Ado.net provider.

2018-02-07 Thread Mark Rotteveel

On 7-2-2018 13:21, Adriano dos Santos Fernandes wrote:

On 07/02/2018 10:17, Mark Rotteveel wrote:


But what causes the observed difference between the example table that
only has an integer id column (and doesn't trigger the AV), and the
one that also has a varchar column and an expression index
(lower(title))?


probably loading of library fbintl.


But wouldn't that mean that fb_shutdown() may be cleaning/closing things 
in the wrong order?


Mark

--
Mark Rotteveel

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] Crash Firebird 2.5.8 Embedded with Firebird Ado.net provider.

2018-02-07 Thread Adriano dos Santos Fernandes
On 07/02/2018 10:17, Mark Rotteveel wrote:
>
> But what causes the observed difference between the example table that
> only has an integer id column (and doesn't trigger the AV), and the
> one that also has a varchar column and an expression index
> (lower(title))?
>
probably loading of library fbintl.


Adriano


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] Crash Firebird 2.5.8 Embedded with Firebird Ado.net provider.

2018-02-07 Thread Mark Rotteveel

On 7-2-2018 12:36, Vlad Khorsun via Firebird-devel wrote:

07.02.2018 13:26, Mark Rotteveel wrote:

On 7-2-2018 11:55, Mark Rotteveel wrote:
Someone reported a crash on shutdown of Firebird 2.5.8 Embedded in a 
C# application on stack overflow: 
https://stackoverflow.com/questions/48644878/appcrash-in-fbintl-dll-if-using-embedded-mode-in-my-c-app. 



I can reproduce it with the provided example application.

I tried to reproduce this by recreating the example using Jaybird, 
but there it works OK. Does anyone have an idea what the cause might 
be, and if this would be something in Firebird Embedded itself, or 
with the ADO.net provider?


I found the cause, the connection pool was active in Firebird ADO.net, 
and the connections weren't closed at the time the engine was unloaded.


Shouldn't the engine be able to cope with this?


   Yes, and fb_shutdown handle it. But it can't handle it correctly when 
process

exits and Windows already unloaded some dlls and kill all other threads.


But what causes the observed difference between the example table that 
only has an integer id column (and doesn't trigger the AV), and the one 
that also has a varchar column and an expression index (lower(title))?


Mark
--
Mark Rotteveel

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] Crash Firebird 2.5.8 Embedded with Firebird Ado.net provider.

2018-02-07 Thread Vlad Khorsun via Firebird-devel

07.02.2018 13:26, Mark Rotteveel wrote:

On 7-2-2018 11:55, Mark Rotteveel wrote:
Someone reported a crash on shutdown of Firebird 2.5.8 Embedded in a C# application on stack overflow: 
https://stackoverflow.com/questions/48644878/appcrash-in-fbintl-dll-if-using-embedded-mode-in-my-c-app.


I can reproduce it with the provided example application.

I tried to reproduce this by recreating the example using Jaybird, but there it works OK. Does anyone have an idea what the cause 
might be, and if this would be something in Firebird Embedded itself, or with the ADO.net provider?


I found the cause, the connection pool was active in Firebird ADO.net, and the connections weren't closed at the time the engine was 
unloaded.


Shouldn't the engine be able to cope with this?


  Yes, and fb_shutdown handle it. But it can't handle it correctly when process
exits and Windows already unloaded some dlls and kill all other threads.

Regards,
Vlad


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] Crash Firebird 2.5.8 Embedded with Firebird Ado.net provider.

2018-02-07 Thread Mark Rotteveel

On 7-2-2018 11:55, Mark Rotteveel wrote:
Someone reported a crash on shutdown of Firebird 2.5.8 Embedded in a C# 
application on stack overflow: 
https://stackoverflow.com/questions/48644878/appcrash-in-fbintl-dll-if-using-embedded-mode-in-my-c-app. 



I can reproduce it with the provided example application.

I tried to reproduce this by recreating the example using Jaybird, but 
there it works OK. Does anyone have an idea what the cause might be, and 
if this would be something in Firebird Embedded itself, or with the 
ADO.net provider?


I found the cause, the connection pool was active in Firebird ADO.net, 
and the connections weren't closed at the time the engine was unloaded.


Shouldn't the engine be able to cope with this?

Mark
--
Mark Rotteveel

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] Crash Firebird 2.5.8 Embedded with Firebird Ado.net provider.

2018-02-07 Thread Vlad Khorsun via Firebird-devel

07.02.2018 12:55, Mark Rotteveel wrote:
Someone reported a crash on shutdown of Firebird 2.5.8 Embedded in a C# application on stack overflow: 
https://stackoverflow.com/questions/48644878/appcrash-in-fbintl-dll-if-using-embedded-mode-in-my-c-app.


I can reproduce it with the provided example application.

I tried to reproduce this by recreating the example using Jaybird, but there it works OK. Does anyone have an idea what the cause 
might be, and if this would be something in Firebird Embedded itself, or with the ADO.net provider?


  fb_shutdown should be called explicitly before fbembed.dll is unloaded. Yes, 
it is
called by fbembed.dll itself on DLL unload but it is not fully safe unless 
library is
unloaded explictly (by FreeLibrary call, not because of process exit).

  Additional problem in case on stackoverflow is not closed database connection
when fbembed.dll is unloaded. It could be a reason why you can't reproduce the
crash. Note, on "clean" exit (with no databases open), fb_shutdown have much 
less
work to do.

Hope it helps,
Vlad

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel