|
View:
New views
16 Messages
—
Rating Filter:
Alert me
|
|
|
writing udf for both windows and linuxHi all
I am writting udf in c++ for both windows and linux. Calling udf with "CSTRING(255) retunrs parameter 1" works fine on windows, but linux not. I am using Borland C++5.5.1 on windows, gcc on linux. On both environment I can build, and test1 is ok, but test2 on linux only not work. Engine crashed. Why is this? This is test case: ---test.cpp--- #include <fstream> #include <string> #include <iostream> #include "sys/stat.h" #ifdef WIN_NT #include <windows> #define EXPORT __declspec(dllexport) #else #define EXPORT #endif using namespace std; extern "C" { EXPORT int test1(int* val) { int ret = *val * 10; return ret; } EXPORT void test2(char* ret) { string str("tomneko"); strcpy(ret, str.c_str()); } }/* extern "C" */ --- DECLARE EXTERNAL FUNCTION TEST1 Integer RETURNS Integer BY VALUE ENTRY_POINT 'test1' MODULE_NAME 'test'; --- DECLARE EXTERNAL FUNCTION TEST2 CSTRING(255) RETURNS PARAMETER 1 ENTRY_POINT 'test2' MODULE_NAME 'test'; --- select test1(1) from rdb$database; retunrs 10. select test2() from rdb$database; retunrs "tomneko" +++++++++++++++++++++++++++++++ >From Tomneko (Tsutomu Hayashi) tomneko.h@... web site http://www.tomnekosoft.com +++++++++++++++++++++++++++++++ ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel |
|
|
Re: writing udf for both windows and linuxHi all
I invesigate this issue after that: * This problem cause on FirebirdSC-2.5Beta2 only. * FirebirdSS-2.5Beta2 and FirebirdCS-2.5Beta2 is OK * FirebirdSS-2.1.2 is OK I guess FirebirdSC-2.5Beta2 is more severe than others? Is this degrade? # My aliases.udf files is attached. 2009/10/27 Tsutomu Hayashi <tomneko.h@...>: > Hi all > > I am writting udf in c++ for both windows and linux. > > Calling udf with "CSTRING(255) retunrs parameter 1" works fine on > windows, but linux not. > > I am using Borland C++5.5.1 on windows, gcc on linux. > > On both environment I can build, and test1 is ok, but test2 on linux > only not work. Engine crashed. > > Why is this? > > This is test case: > > ---test.cpp--- > > #include <fstream> > #include <string> > #include <iostream> > #include "sys/stat.h" > #ifdef WIN_NT > #include <windows> > #define EXPORT __declspec(dllexport) > #else > #define EXPORT > #endif > > using namespace std; > > extern "C" { > > EXPORT int test1(int* val) > { > int ret = *val * 10; > return ret; > } > > EXPORT void test2(char* ret) > { > string str("tomneko"); > strcpy(ret, str.c_str()); > } > > }/* extern "C" */ > > --- > DECLARE EXTERNAL FUNCTION TEST1 > Integer > RETURNS Integer BY VALUE > ENTRY_POINT 'test1' > MODULE_NAME 'test'; > > --- > DECLARE EXTERNAL FUNCTION TEST2 > CSTRING(255) > RETURNS PARAMETER 1 > ENTRY_POINT 'test2' > MODULE_NAME 'test'; > > --- > select test1(1) from rdb$database; retunrs 10. > > select test2() from rdb$database; retunrs "tomneko" > > tomneko.h@... web site http://www.tomnekosoft.com +++++++++++++++++++++++++++++++ ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel |
|
|
Re: writing udf for both windows and linuxOn Tuesday 03 November 2009 08:03:20 Tsutomu Hayashi wrote:
> Hi all > > I invesigate this issue after that: > > * This problem cause on FirebirdSC-2.5Beta2 only. > * FirebirdSS-2.5Beta2 and FirebirdCS-2.5Beta2 is OK > * FirebirdSS-2.1.2 is OK > > I guess FirebirdSC-2.5Beta2 is more severe than others? Is this degrade? > > # My aliases.udf files is attached. You miss one required switch in gcc command line: -fPIC: g++ -fPIC -shared -O2 -pthread -Wall aliases_udf.cpp -o aliases_udf.so With it works like a charm. PS. Such UDF may be a kind of security problem for your system. It provides information normally hidden from remote users, specially when alias-only access (DatabaseAccess=None in firebird.conf) is used. ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel |
|
|
Re: writing udf for both windows and linuxHi Alex
Thanks for your reply! Sory, I miss this switch. ;-) Why I think to create these functions, so InterBase now can handle aliases from remote bebcause InterBase handled aliases in it's security database "admin.ib". Firebird can't handle aliases from remote. And these functions I created has security problem because UDFs is out of privileges. So any users can execute these functions once it registered, this is truely problem. I will avoid these problems to impliment authentication mechanism into this library. Thanks! 2009/11/3 Alexander Peshkoff <peshkoff@...>: > On Tuesday 03 November 2009 08:03:20 Tsutomu Hayashi wrote: >> Hi all >> >> I invesigate this issue after that: >> >> * This problem cause on FirebirdSC-2.5Beta2 only. >> * FirebirdSS-2.5Beta2 and FirebirdCS-2.5Beta2 is OK >> * FirebirdSS-2.1.2 is OK >> >> I guess FirebirdSC-2.5Beta2 is more severe than others? Is this degrade? >> >> # My aliases.udf files is attached. > > You miss one required switch in gcc command line: -fPIC: > g++ -fPIC -shared -O2 -pthread -Wall aliases_udf.cpp -o aliases_udf.so > With it works like a charm. > > PS. Such UDF may be a kind of security problem for your system. It provides > information normally hidden from remote users, specially when alias-only > access (DatabaseAccess=None in firebird.conf) is used. > +++++++++++++++++++++++++++++++ >From Tomneko (Tsutomu Hayashi) tomneko.h@... web site http://www.tomnekosoft.com +++++++++++++++++++++++++++++++ ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel |
|
|
Re: writing udf for both windows and linuxHi Alex
Sory, I tested with -fPIC (and -pthread) switch. But now still engine stalled... ;-) >g++ -fPIC -shared -O2 -pthread -Wall aliases_udf.cpp -o aliases_udf.so Only with Firebird SuperClassic 2.5-Beta2 running on CentOS5.3. 2009/11/4 Tsutomu Hayashi <tomneko.h@...>: > Hi Alex > > Thanks for your reply! > > Sory, I miss this switch. ;-) > > Why I think to create these functions, so InterBase now can handle > aliases from remote bebcause InterBase handled aliases in it's > security database "admin.ib". > > Firebird can't handle aliases from remote. And these functions I > created has security problem because UDFs is out of privileges. So any > users can execute these functions once it registered, this is truely > problem. > > I will avoid these problems to impliment authentication mechanism into > this library. > > Thanks! > > 2009/11/3 Alexander Peshkoff <peshkoff@...>: >> On Tuesday 03 November 2009 08:03:20 Tsutomu Hayashi wrote: >>> Hi all >>> >>> I invesigate this issue after that: >>> >>> * This problem cause on FirebirdSC-2.5Beta2 only. >>> * FirebirdSS-2.5Beta2 and FirebirdCS-2.5Beta2 is OK >>> * FirebirdSS-2.1.2 is OK >>> >>> I guess FirebirdSC-2.5Beta2 is more severe than others? Is this degrade? >>> >>> # My aliases.udf files is attached. >> >> You miss one required switch in gcc command line: -fPIC: >> g++ -fPIC -shared -O2 -pthread -Wall aliases_udf.cpp -o aliases_udf.so >> With it works like a charm. >> >> PS. Such UDF may be a kind of security problem for your system. It provides >> information normally hidden from remote users, specially when alias-only >> access (DatabaseAccess=None in firebird.conf) is used. >> > > +++++++++++++++++++++++++++++++ > From Tomneko (Tsutomu Hayashi) > tomneko.h@... > web site http://www.tomnekosoft.com > +++++++++++++++++++++++++++++++ > ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel |
|
|
Re: writing udf for both windows and linuxTsutomu,
> Why I think to create these functions, so InterBase now can handle > aliases from remote bebcause InterBase handled aliases in it's > security database "admin.ib". > > Firebird can't handle aliases from remote. Please explain/elaborate... Firebird *does* support aliases. Sean ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel |
|
|
Re: writing udf for both windows and linuxHi Sean
I now have InterBase 2009, this can handle server side database aliases using IBConsole. Using IBConsole attache database, and execute "Database Aliases" command, then show aliases list "name - path". And I can delete alias with this list. And I can add alias at database property dialog. See this url. http://edn.embarcadero.com/jp/article/37600 I am afraid that InterBase API manual not contains this functionality, but only in OpGuide using with gsec alias_add/alias_dis/alias_del command. But IBConsole can handle aliases remotely, I guess to be expanded the Service API isc_action_svc_add_alias/isc_action_svc_display_aliases/isc_action_svc_delete_alias. 2009/11/4 Leyne, Sean <Sean@...>: > Tsutomu, > >> Why I think to create these functions, so InterBase now can handle >> aliases from remote bebcause InterBase handled aliases in it's >> security database "admin.ib". >> >> Firebird can't handle aliases from remote. > > Please explain/elaborate... > > Firebird *does* support aliases. > > > Sean > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel > -- +++++++++++++++++++++++++++++++ >From Tomneko (Tsutomu Hayashi) tomneko.h@... web site http://www.tomnekosoft.com +++++++++++++++++++++++++++++++ ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel |
|
|
Re: writing udf for both windows and linuxOn Wednesday 04 November 2009 03:37:36 Tsutomu Hayashi wrote:
> Hi Sean > > I now have InterBase 2009, this can handle server side database > aliases using IBConsole. > > Using IBConsole attache database, and execute "Database Aliases" > command, then show aliases list "name - path". And I can delete alias > with this list. And I can add alias at database property dialog. > > See this url. > > http://edn.embarcadero.com/jp/article/37600 > > I am afraid that InterBase API manual not contains this functionality, > but only in OpGuide using with gsec alias_add/alias_dis/alias_del > command. > > But IBConsole can handle aliases remotely, I guess to be expanded the > Service API > isc_action_svc_add_alias/isc_action_svc_display_aliases/isc_action_svc_dele >te_alias. I like this idea. Suppose we can do it in FB3. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel |
|
|
Re: writing udf for both windows and linuxHi Alex
> I like this idea. Suppose we can do it in FB3. Adding that, I want whole databases catalog. In administrative aspects this functionality strongly needed. 2009/11/4 Alexander Peshkoff <peshkoff@...>: > On Wednesday 04 November 2009 03:37:36 Tsutomu Hayashi wrote: >> Hi Sean >> >> I now have InterBase 2009, this can handle server side database >> aliases using IBConsole. >> >> Using IBConsole attache database, and execute "Database Aliases" >> command, then show aliases list "name - path". And I can delete alias >> with this list. And I can add alias at database property dialog. >> >> See this url. >> >> http://edn.embarcadero.com/jp/article/37600 >> >> I am afraid that InterBase API manual not contains this functionality, >> but only in OpGuide using with gsec alias_add/alias_dis/alias_del >> command. >> >> But IBConsole can handle aliases remotely, I guess to be expanded the >> Service API >> isc_action_svc_add_alias/isc_action_svc_display_aliases/isc_action_svc_dele >>te_alias. > > I like this idea. Suppose we can do it in FB3. > -- +++++++++++++++++++++++++++++++ >From Tomneko (Tsutomu Hayashi) tomneko.h@... web site http://www.tomnekosoft.com +++++++++++++++++++++++++++++++ ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel |
|
|
Re: writing udf for both windows and linuxOn Wednesday 04 November 2009 01:44:10 Tsutomu Hayashi wrote:
> Hi Alex > > Sory, I tested with -fPIC (and -pthread) switch. But now still engine > stalled... ;-) > > >g++ -fPIC -shared -O2 -pthread -Wall aliases_udf.cpp -o aliases_udf.so > > Only with Firebird SuperClassic 2.5-Beta2 running on CentOS5.3. Indeed, with distributed binaries this fails. The reason is that fb_smp_server exports all symbols, including redefined global operators delete and new. But for some not clear for me at once reasons your UDF is using standard (using malloc()) operator new, but non-standard (exported from fb_smp_server) operator delete. Certainly delete code segfaults. I will try to make fb_smp_server not export any symbols. The simplest solution for you right now is not to use STL in UDFs. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel |
|
|
Re: writing udf for both windows and linuxOn Wednesday 04 November 2009 13:38:11 Tsutomu Hayashi wrote:
> Hi Alex > > > I like this idea. Suppose we can do it in FB3. > > Adding that, I want whole databases catalog. In administrative aspects > this functionality strongly needed. Ahh, looks like I hurried a bit. One of text conf file features was making them read-only for server process. The reason is to avoid changing files in case when a king of BOF attack is succeeded against server process and attacker get's able to execute arbitrary code with server rights. I.e. we can provide list of aliases outside, but can't change them. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel |
|
|
Re: writing udf for both windows and linuxAlexander Peshkoff escreveu:
> On Wednesday 04 November 2009 01:44:10 Tsutomu Hayashi wrote: > >> Hi Alex >> >> Sory, I tested with -fPIC (and -pthread) switch. But now still engine >> stalled... ;-) >> >> >>> g++ -fPIC -shared -O2 -pthread -Wall aliases_udf.cpp -o aliases_udf.so >>> >> Only with Firebird SuperClassic 2.5-Beta2 running on CentOS5.3. >> > > Indeed, with distributed binaries this fails. > The reason is that fb_smp_server exports all symbols, including redefined > global operators delete and new. But for some not clear for me at once > reasons your UDF is using standard (using malloc()) operator new, but > non-standard (exported from fb_smp_server) operator delete. Certainly delete > code segfaults. > > I will try to make fb_smp_server not export any symbols. The simplest solution > for you right now is not to use STL in UDFs. I've fixed it with empty version script file in 3.0. Adriano ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel |
|
|
Re: writing udf for both windows and linuxOn Wednesday 04 November 2009 13:50:15 Adriano dos Santos Fernandes wrote:
> Alexander Peshkoff escreveu: > > On Wednesday 04 November 2009 01:44:10 Tsutomu Hayashi wrote: > >> Hi Alex > >> > >> Sory, I tested with -fPIC (and -pthread) switch. But now still engine > >> stalled... ;-) > >> > >>> g++ -fPIC -shared -O2 -pthread -Wall aliases_udf.cpp -o aliases_udf.so > >> > >> Only with Firebird SuperClassic 2.5-Beta2 running on CentOS5.3. > > > > Indeed, with distributed binaries this fails. > > The reason is that fb_smp_server exports all symbols, including redefined > > global operators delete and new. But for some not clear for me at once > > reasons your UDF is using standard (using malloc()) operator new, but > > non-standard (exported from fb_smp_server) operator delete. Certainly > > delete code segfaults. > > > > I will try to make fb_smp_server not export any symbols. The simplest > > solution for you right now is not to use STL in UDFs. > > Alex, this caused a lot of problem for me with Java plugin once. AFAIR, > I've fixed it with empty version script file in 3.0. I suggest you to backport your changes for RC2 in this case. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel |
|
|
Re: writing udf for both windows and linuxHi Alex
> Indeed, with distributed binaries this fails. > The reason is that fb_smp_server exports all symbols, including redefined > global operators delete and new. But for some not clear for me at once > reasons your UDF is using standard (using malloc()) operator new, but > non-standard (exported from fb_smp_server) operator delete. Certainly delete > code segfaults. MySQL and PostgreSQL both have systema catalog include database. For example: mysql>show database psql>\list And both can change database with these command line utilities. mysql>use database-name psql>\c database-name IFAIK these are defact standard. > I will try to make fb_smp_server not export any symbols. The simplest solution > for you right now is not to use STL in UDFs. I see. But I don't return pointer I created... -- +++++++++++++++++++++++++++++++ >From Tomneko (Tsutomu Hayashi) tomneko.h@... web site http://www.tomnekosoft.com +++++++++++++++++++++++++++++++ ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel |
|
|
Re: writing udf for both windows and linuxSory I returned this sentense...
--- Ahh, looks like I hurried a bit. One of text conf file features was making them read-only for server process. The reason is to avoid changing files in case when a king of BOF attack is succeeded against server process and attacker get's able to execute arbitrary code with server rights. I.e. we can provide list of aliases outside, but can't change them. --- > MySQL and PostgreSQL both have systema catalog include database. For example: > > mysql>show database > > psql>\list > > And both can change database with these command line utilities. > > mysql>use database-name > > psql>\c database-name > > IFAIK these are defact standard. > +++++++++++++++++++++++++++++++ From Tomneko (Tsutomu Hayashi) tomneko.h@... web site http://www.tomnekosoft.com +++++++++++++++++++++++++++++++ ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel |
|
|
Re: writing udf for both windows and linuxOn Thursday 05 November 2009 04:48:16 Tsutomu Hayashi wrote:
> Hi Alex > > > Indeed, with distributed binaries this fails. > > The reason is that fb_smp_server exports all symbols, including redefined > > global operators delete and new. But for some not clear for me at once > > reasons your UDF is using standard (using malloc()) operator new, but > > non-standard (exported from fb_smp_server) operator delete. Certainly > > delete code segfaults. > > MySQL and PostgreSQL both have systema catalog include database. For > example: > > mysql>show database > > psql>\list > > And both can change database with these command line utilities. > > mysql>use database-name > > psql>\c database-name > > IFAIK these are defact standard. You mix database servers that always keep track of all known databases and firebird, that was from the early days designed to access any database file, without first registering it in some way. But I see no problems showing aliases list (certainly, some security restrictions will apply). > > I will try to make fb_smp_server not export any symbols. The simplest > > solution for you right now is not to use STL in UDFs. > > I see. But I don't return pointer I created... I know :-) The reason of AV is operator delete, called by destructor of STL's class string. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel |
| Free embeddable forum powered by Nabble | Forum Help |