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

Engine crashs in case of re-creation of an erratic package body [CORE4271] #4595

Closed
firebird-issue-importer opened this issue Nov 19, 2013 · 11 comments

Comments

@firebird-issue-importer

Submitted by: @sim1984

Attachments:
pack.sql

Use CONNECT or CREATE DATABASE to specify a database
SQL> set names win1251;
SQL> create database 'localhost/3051:d:/interbasedata/3.0/test.fdb' user 'sysdba' password 'masterkey' page_size 8192 DE
FAULT CHARACTER SET WIN1251;
SQL> SET TERM ^;
SQL>
SQL> CREATE OR ALTER PACKAGE PKG_SEQUENCE
CON> AS
CON> BEGIN
CON> PROCEDURE INITIALIZE(MIN_VALUE INTEGER, MAX_VALUE INTEGER, STEP INTEGER);
CON>
CON> FUNCTION GET_CURRENT_VALUE RETURNS INTEGER;
CON>
CON> FUNCTION NEXT_VALUE RETURNS INTEGER;
CON>
CON> FUNCTION IS_END RETURNS BOOLEAN;
CON> END^
SQL>
SQL> RECREATE PACKAGE BODY PKG_SEQUENCE
CON> AS
CON> BEGIN
CON>
CON> FUNCTION GET_MAX RETURNS INTEGER
CON> AS
CON> BEGIN
CON> RETURN CAST(RDB$GET_CONTEXT('USER_SESSION', 'MAX_VALUE') AS INTEGER);
CON> END
CON>
CON> FUNCTION SET_MAX(AVALUE INTEGER) RETURNS INTEGER
CON> AS
CON> BEGIN
CON> RDB$SET_CONTEXT('USER_SESSION', 'MAX_VALUE', AVALUE);
CON> RETURN AVALUE;
CON> END
CON>
CON> FUNCTION GET_MIN RETURNS INTEGER
CON> AS
CON> BEGIN
CON> RETURN CAST(RDB$GET_CONTEXT('USER_SESSION', 'MIN_VALUE') AS INTEGER);
CON> END
CON>
CON> FUNCTION SET_MIN(AVALUE INTEGER) RETURNS INTEGER
CON> AS
CON> BEGIN
CON> RDB$SET_CONTEXT('USER_SESSION', 'MIN_VALUE', AVALUE);
CON> RETURN AVALUE;
CON> END
CON>
CON> FUNCTION GET_STEP RETURNS INTEGER
CON> AS
CON> BEGIN
CON> RETURN CAST(RDB$GET_CONTEXT('USER_SESSION', 'STEP_VALUE') AS INTEGER);
CON> END
CON>
CON> FUNCTION SET_STEP(AVALUE INTEGER) RETURNS INTEGER
CON> AS
CON> BEGIN
CON> RDB$SET_CONTEXT('USER_SESSION', 'STEP_VALUE', AVALUE);
CON> RETURN AVALUE;
CON> END
CON>
CON> FUNCTION GET_CURRENT_VALUE RETURNS INTEGER
CON> AS
CON> BEGIN
CON> RETURN CAST(RDB$GET_CONTEXT('USER_SESSION', 'CURRENT_VALUE') AS INTEGER);
CON> END
CON>
CON> FUNCTION SET_CURRENT_VALUE(AVALUE INTEGER) RETURNS INTEGER
CON> AS
CON> BEGIN
CON> RDB$SET_CONTEXT('USER_SESSION', 'CURRENT_VALUE', AVALUE);
CON> RETURN AVALUE;
CON> END
CON>
CON> FUNCTION NEXT_VALUE RETURNS INTEGER
CON> AS
CON> BEGIN
CON> IF (NOT IS_END()) THEN
CON> SET_CURRENT_VALUE(GET_CURRENT_VALUE() + GET_STEP());
CON> RETURN GET_CURRENT_VALUE();
CON> END
CON>
CON> FUNCTION IS_END RETURNS BOOLEAN
CON> AS
CON> BEGIN
CON> RETURN GET_CURRENT_VALUE() > GET_MAX();
CON> END
CON>
CON> PROCEDURE INITIALIZE(MIN_VALUE INTEGER, MAX_VALUE INTEGER, STEP INTEGER)
CON> AS
CON> BEGIN
CON> SET_MIN(MIN_VALUE);
CON> SET_MAX(MAX_VALUE);
CON> SET_STEP(STEP);
CON> SET_CURRENT_VALUE(MIN_VALUE);
CON> END
CON>
CON> END^
SQL>
SQL> EXECUTE BLOCK
CON> RETURNS (
CON> OUT INTEGER)
CON> AS
CON> BEGIN
CON> EXECUTE PROCEDURE PKG_SEQUENCE.INITIALIZE(10, 140, 5);
CON> OUT = PKG_SEQUENCE.GET_CURRENT_VALUE();
CON> SUSPEND;
CON> WHILE (NOT PKG_SEQUENCE.IS_END()) DO
CON> BEGIN
CON> OUT = PKG_SEQUENCE.NEXT_VALUE();
CON> SUSPEND;
CON> END
CON> END^

     OUT

============
10
Statement failed, SQLSTATE = 2F000
Cannot execute function IS_END of the unimplemented package PKG_SEQUENCE
-At function 'PKG_SEQUENCE.NEXT_VALUE' line: 60, col: 5
SQL> RECREATE PACKAGE BODY PKG_SEQUENCE
CON> AS
CON> BEGIN
CON>
CON> FUNCTION GET_MAX RETURNS INTEGER
CON> AS
CON> BEGIN
CON> RETURN CAST(RDB$GET_CONTEXT('USER_SESSION', 'MAX_VALUE') AS INTEGER);
CON> END
CON>
CON> FUNCTION SET_MAX(AVALUE INTEGER) RETURNS INTEGER
CON> AS
CON> BEGIN
CON> RDB$SET_CONTEXT('USER_SESSION', 'MAX_VALUE', AVALUE);
CON> RETURN AVALUE;
CON> END
CON>
CON> FUNCTION GET_MIN RETURNS INTEGER
CON> AS
CON> BEGIN
CON> RETURN CAST(RDB$GET_CONTEXT('USER_SESSION', 'MIN_VALUE') AS INTEGER);
CON> END
CON>
CON> FUNCTION SET_MIN(AVALUE INTEGER) RETURNS INTEGER
CON> AS
CON> BEGIN
CON> RDB$SET_CONTEXT('USER_SESSION', 'MIN_VALUE', AVALUE);
CON> RETURN AVALUE;
CON> END
CON>
CON> FUNCTION GET_STEP RETURNS INTEGER
CON> AS
CON> BEGIN
CON> RETURN CAST(RDB$GET_CONTEXT('USER_SESSION', 'STEP_VALUE') AS INTEGER);
CON> END
CON>
CON> FUNCTION SET_STEP(AVALUE INTEGER) RETURNS INTEGER
CON> AS
CON> BEGIN
CON> RDB$SET_CONTEXT('USER_SESSION', 'STEP_VALUE', AVALUE);
CON> RETURN AVALUE;
CON> END
CON>
CON> FUNCTION GET_CURRENT_VALUE RETURNS INTEGER
CON> AS
CON> BEGIN
CON> RETURN CAST(RDB$GET_CONTEXT('USER_SESSION', 'CURRENT_VALUE') AS INTEGER);
CON> END
CON>
CON> FUNCTION SET_CURRENT_VALUE(AVALUE INTEGER) RETURNS INTEGER
CON> AS
CON> BEGIN
CON> RDB$SET_CONTEXT('USER_SESSION', 'CURRENT_VALUE', AVALUE);
CON> RETURN AVALUE;
CON> END
CON>
CON> FUNCTION NEXT_VALUE RETURNS INTEGER
CON> AS
CON> BEGIN
CON> IF (NOT IS_END()) THEN
CON> SET_CURRENT_VALUE(GET_CURRENT_VALUE() + GET_STEP());
CON> RETURN GET_CURRENT_VALUE();
CON> END
CON>
CON> FUNCTION IS_END RETURNS BOOLEAN
CON> AS
CON> BEGIN
CON> RETURN GET_CURRENT_VALUE() > GET_MAX();
CON> END
CON>
CON> PROCEDURE INITIALIZE(MIN_VALUE INTEGER, MAX_VALUE INTEGER, STEP INTEGER)
CON> AS
CON> BEGIN
CON> SET_MIN(MIN_VALUE);
CON> SET_MAX(MAX_VALUE);
CON> SET_STEP(STEP);
CON> SET_CURRENT_VALUE(MIN_VALUE);
CON> END
CON>
CON> END^
SQL> EXECUTE BLOCK
CON> RETURNS (
CON> OUT INTEGER)
CON> AS
CON> BEGIN
CON> EXECUTE PROCEDURE PKG_SEQUENCE.INITIALIZE(10, 140, 5);
CON> OUT = PKG_SEQUENCE.GET_CURRENT_VALUE();
CON> SUSPEND;
CON> WHILE (NOT PKG_SEQUENCE.IS_END()) DO
CON> BEGIN
CON> OUT = PKG_SEQUENCE.NEXT_VALUE();
CON> SUSPEND;
CON> END
CON> END^
Statement failed, SQLSTATE = 08006
Error reading data from the connection.
SQL>

Commits: 5b790ef 2aa3e8d FirebirdSQL/fbt-repository@6f9890f FirebirdSQL/fbt-repository@0edd5b9

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Nov 19, 2013

Commented by: @sim1984

script package attached

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Nov 19, 2013

Modified by: @sim1984

Attachment: pack.sql [ 12386 ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Nov 20, 2013

Modified by: @dyemanov

summary: Crash engine in case of re-creation of an erratic body of a packet => Crash engine in case of re-creation of an erratic package body

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Nov 20, 2013

Modified by: @dyemanov

assignee: Adriano dos Santos Fernandes [ asfernandes ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Nov 25, 2013

Commented by: @asfernandes

Simple test case for first half of the problem (problem with functions and the metadata cache):

CREATE OR ALTER PACKAGE PKG_SEQUENCE
AS
BEGIN
PROCEDURE NEXT_VALUE;
FUNCTION IS_END RETURNS BOOLEAN;
END!

RECREATE PACKAGE BODY PKG_SEQUENCE
AS
BEGIN
FUNCTION IS_END RETURNS BOOLEAN
AS
BEGIN
RETURN FALSE;
END

PROCEDURE NEXT_VALUE
AS
BEGIN
IS_END();
END
END!

EXECUTE BLOCK
RETURNS (OUT INTEGER)
AS
BEGIN
EXECUTE PROCEDURE PKG_SEQUENCE.NEXT_VALUE;
SUSPEND;
END!

     OUT 

============
Statement failed, SQLSTATE = 2F000
Cannot execute function IS_END of the unimplemented package PKG_SEQUENCE
-At procedure 'PKG_SEQUENCE.NEXT_VALUE' line: 13, col: 5

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Dec 14, 2013

Commented by: @sim1984

After changing the creation of 58934 attached package is successful.
However, after re-create the package body. Execution unit attached to the ticket causes the server to crash

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Dec 14, 2013

Commented by: @asfernandes

> However, after re-create the package body. Execution unit attached to the ticket causes the server to crash

It's the reason the ticket is not marked as resolved yet.

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Dec 16, 2013

Modified by: @asfernandes

summary: Crash engine in case of re-creation of an erratic package body => Engine crashs in case of re-creation of an erratic package body

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Dec 16, 2013

Modified by: @asfernandes

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

resolution: Fixed [ 1 ]

Fix Version: 3.0 Alpha 2 [ 10560 ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Mar 27, 2014

Modified by: @pcisar

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

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented May 29, 2015

Modified by: @pavel-zotov

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

QA Status: 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

2 participants