Re: [Firebird-devel] Handling exception from external plugins
On 4/12/22 11:53, Roman Simakov wrote: Alex, Is it documented somewhere? Exactly in this form - not. I.e. a fact that exceptions are caught when throwing from OO API functions is documented (in Using_OO_API) and special position of FbException is documented too, but need of first Status parameter to make all that work is not emphasized. To be precise - _any_ exception in _any_ OO API function will be caught, but it will not be delivered in original way to caller. The humor is that FB_PLUGIN_ENTRY_POINT (except missing Status parameter) is not OO API call - it's just plain C function which is needed to 'boot' OO API in plugin, and certainly it should not throw over module boundaries. пн, 11 апр. 2022 г. в 18:45, Alex Peshkoff via Firebird-devel : On 4/11/22 17:56, Dimitry Sibiryakov wrote: Vasiliy Yashkov wrote 11.04.2022 16:52: What is the right way to throw an exception? Plugins (as any other DLL) is not supposed to throw exceptions ever. Yes, throwing directly (like in your code) is impossible. But there is a way to return an exception information from plugin using Status interface, which is passed as first parameter in that case. Pay attention - FB_PLUGIN_ENTRY_POINT has no such parameter and therefore is not expected to return exception information. (there are more reasons why exceptions not to be used in that call but let me not dive too deep here) But if some plugin entry has first Status parameter you can throw FbException in it, it will be caught by thin API layer which actually invoked your plugin entry and delivered to the code which called plugin. 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
Re: [Firebird-devel] Handling exception from external plugins
Alex, Is it documented somewhere? пн, 11 апр. 2022 г. в 18:45, Alex Peshkoff via Firebird-devel : > > On 4/11/22 17:56, Dimitry Sibiryakov wrote: > > Vasiliy Yashkov wrote 11.04.2022 16:52: > >> What is the right way to throw an exception? > > > > Plugins (as any other DLL) is not supposed to throw exceptions ever. > > > > Yes, throwing directly (like in your code) is impossible. But there is a > way to return an exception information from plugin using Status > interface, which is passed as first parameter in that case. > Pay attention - FB_PLUGIN_ENTRY_POINT has no such parameter and > therefore is not expected to return exception information. (there are > more reasons why exceptions not to be used in that call but let me not > dive too deep here) > > But if some plugin entry has first Status parameter you can throw > FbException in it, it will be caught by thin API layer which actually > invoked your plugin entry and delivered to the code which called plugin. > > > > > 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
Re: [Firebird-devel] Handling exception from external plugins
Ok, now I get it. Thanks for the explanations! -- Vasiliy Yashkov Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Handling exception from external plugins
On 4/11/22 17:56, Dimitry Sibiryakov wrote: Vasiliy Yashkov wrote 11.04.2022 16:52: What is the right way to throw an exception? Plugins (as any other DLL) is not supposed to throw exceptions ever. Yes, throwing directly (like in your code) is impossible. But there is a way to return an exception information from plugin using Status interface, which is passed as first parameter in that case. Pay attention - FB_PLUGIN_ENTRY_POINT has no such parameter and therefore is not expected to return exception information. (there are more reasons why exceptions not to be used in that call but let me not dive too deep here) But if some plugin entry has first Status parameter you can throw FbException in it, it will be caught by thin API layer which actually invoked your plugin entry and delivered to the code which called plugin. Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
Re: [Firebird-devel] Handling exception from external plugins
Vasiliy Yashkov wrote 11.04.2022 16:52: What is the right way to throw an exception? Plugins (as any other DLL) is not supposed to throw exceptions ever. -- WBR, SD. Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel
[Firebird-devel] Handling exception from external plugins
Hi All! I have a simple external plugin that throws an exception: #include "firebird/Interface.h" using namespace Firebird; extern "C" void FB_DLL_EXPORT FB_PLUGIN_ENTRY_POINT(IMaster* master) { const auto status = master->getStatus(); ISC_STATUS vector[] = { isc_arg_gds, isc_random, isc_arg_string, (ISC_STATUS) "Unable to initialize module", isc_arg_end}; const auto ex = FbException(status, vector); status->dispose(); throw ex; } But when an exception throws, server crashes with SIGSEGV: Thread 5 "firebird" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x71075640 (LWP 387536)] 0x77c71069 in get_adjusted_ptr(std::type_info const*, std::type_info const*, void**) () from /home/vasiliy/dev/github/firebird/gen/Debug/firebird/lib/libfbclient.so.2 (gdb) bt #0 0x77c71069 in get_adjusted_ptr(std::type_info const*, std::type_info const*, void**) () from /home/vasiliy/dev/github/firebird/gen/Debug/firebird/lib/libfbclient.so.2 #1 0x77c7197e in __gxx_personality_v0 () from /home/vasiliy/dev/github/firebird/gen/Debug/firebird/lib/libfbclient.so.2 #2 0x7792e484 in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1 #3 0x7792eebe in _Unwind_Resume () from /lib/x86_64-linux-gnu/libgcc_s.so.1 #4 0x77ad5de7 in (anonymous namespace)::PluginSet::loadModule (this=0x77fc0ce0, info=...) at /home/vasiliy/dev/github/firebird/src/yvalve/PluginManager.cpp:952 #5 0x77ad5366 in (anonymous namespace)::PluginSet::next (this=0x77fc0ce0, status=0x71072790) at /home/vasiliy/dev/github/firebird/src/yvalve/PluginManager.cpp:877 #6 0x77ad4f15 in (anonymous namespace)::PluginSet::PluginSet (this=0x77fc0ce0, pinterfaceType=11, pnamesList=0x71072acc "Debezium_Connector", fbConf=0x0) at /home/vasiliy/dev/github/firebird/src/yvalve/PluginManager.cpp:814 #7 0x77ad671d in Firebird::PluginManager::getPlugins ( this=0x77f92210 , status=0x71072950, interfaceType=11, namesList=0x71072acc "Debezium_Connector", firebirdConf=0x0) at /home/vasiliy/dev/github/firebird/src/yvalve/PluginManager.cpp:1076 #8 0x77ae3bad in Firebird::IPluginManagerBaseImplFirebird::CheckStatusWrapper, Firebird::IVersionedImplFirebird::CheckStatusWrapper, Firebird::Inherit > >::cloopgetPluginsDispatcher ( self=0x77f92218 , status=0x71072bf0, pluginType=11, namesList=0x71072acc "Replicator_Plugin", firebirdConf=0x0) at /home/vasiliy/dev/github/firebird/src/include/firebird/IdlFbInterfaces.h:8121 #9 0x750db385 in Firebird::IPluginManager::getPlugins ( this=0x77f92218 ... What is the right way to throw an exception? Or it is a bug? Environment: Firebird master Ubuntu 21.10 gcc (Ubuntu 11.2.0-7ubuntu2) 11.2.0 -- Vasiliy Yaskov Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel