Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinity from UDF should be trapped by the engine [CORE2582] #2992

Closed
firebird-automations opened this issue Aug 5, 2009 · 10 comments
Closed

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Claudio Valderrama C. (robocop)

Assigned to: Claudio Valderrama C. (robocop)

Is related to QA410

This is related to CORE2581 Infinity should not escape from the engine
In only tested FB2.5, but maybe FB2.1 behaves the same.
In Windows, there's a __try/__catch block around UDF execution to trap several special conditions. Normally the answer from these conditions is engine shutdown.
I think that in case of overflow, we don't need to panic. We simply need to convert it to an exception about FP overflow.
But I wonder why the protection block used by the Windows build is not working: it should invoke ISC_exception_post() in isc_sync.cpp.

SQL> declare external function dPower
CON> double precision by descriptor, double precision by descriptor,
CON> double precision by descriptor
CON> returns parameter 3
CON> entry_point 'power' module_name 'fbudf';
SQL> select dpower(10e+110, 3) from rdb$database;

             DPOWER

=======================
Infinity

C.

Commits: 13a0547 b22b7dc FirebirdSQL/fbt-repository@aa5fc83

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

As far as I can see, the CRT function POW() used in that UDF simply doesn't throw any exception, so there's nothing to catch.

@firebird-automations
Copy link
Collaborator Author

Commented by: Claudio Valderrama C. (robocop)

In this case, Infinity will have to be detected in fun.epp directly.

@firebird-automations
Copy link
Collaborator Author

Modified by: Claudio Valderrama C. (robocop)

assignee: Claudio Valderrama C. [ robocop ]

@firebird-automations
Copy link
Collaborator Author

Commented by: Claudio Valderrama C. (robocop)

Given these declarations:

DECLARE EXTERNAL FUNCTION DPOWER
DOUBLE PRECISION BY DESCRIPTOR, DOUBLE PRECISION BY DESCRIPTOR, DOUBLE PRECISION BY DESCRIPTOR
RETURNS PARAMETER 3
ENTRY_POINT 'power' MODULE_NAME 'fbudf';

DECLARE EXTERNAL FUNCTION XASIN
DOUBLE PRECISION
RETURNS DOUBLE PRECISION BY VALUE
ENTRY_POINT 'IB_UDF_asin' MODULE_NAME 'ib_udf';

DECLARE EXTERNAL FUNCTION XDIV
INTEGER, INTEGER
RETURNS DOUBLE PRECISION BY VALUE
ENTRY_POINT 'IB_UDF_div' MODULE_NAME 'ib_udf';

the expected answer from the engine is:

SQL> select dpower(1e120, 3) from rdb$database;

             DPOWER

=======================
Statement failed, SQLSTATE = 39000
expression evaluation not supported
-Floating point overflow in result from UDF DPOWER
SQL> select xasin(2) from rdb$database;

              XASIN

=======================
Statement failed, SQLSTATE = 39000
expression evaluation not supported
-Invalid floating point value returned by UDF XASIN
SQL> show functions;
DPOWER XASIN
XDIV
SQL> select xdiv(10, 0) from rdb$database;

               XDIV

=======================
Statement failed, SQLSTATE = 39000
expression evaluation not supported
-Floating point overflow in result from UDF XDIV

@firebird-automations
Copy link
Collaborator Author

Modified by: Claudio Valderrama C. (robocop)

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 2.5 RC1 [ 10362 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Link: This issue is related to QA410 [ QA410 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @pcisar

QA test added.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

QA Status: No test

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

QA Status: No test => Done successfully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant