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

Crash on infinite mutual SP calls (instead of "Too many concurrent executions of the same request.") [CORE4653] #1599

Closed
firebird-automations opened this issue Dec 27, 2014 · 15 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @pavel-zotov

Is related to CORE4688

Attachments:
gdb-coredump-when-attempt-to-run-infinite-SP-calls.zip

set term ^;
create or alter procedure p03(a_i int) returns (z int) as
begin
z = 0 ;
suspend;
end^
commit^

create or alter procedure p02(a_i int) returns (z int) as
begin
z = (select z from p03(:a_i)) + 1;
suspend;
end^
commit^

create or alter procedure p03(a_i int) returns (z int) as
begin
z = (select z from p02(:a_i)) + 1;
suspend;
end^
commit^

create or alter procedure p01(a_i int) returns (z int) as
begin
z = (select z from p02(:a_i)) + 1;
suspend;
end^
commit^
set term ;^

SQL> show proc;
Global procedures:
Procedure Name Invalid Dependency, Type
================================= ======= =================
P01 P02, Procedure
P02 P03, Procedure
P03 P02, Procedure

This statement:

SQL> select * from p01(1);

-- leads FB to "Segmentation fault (core dumped)"

Stacktrace samples see in attach.

SQL> show version;
ISQL Version: LI-T3.0.0.31474 Firebird 3.0 Beta 2
Server version:
Firebird/Linux/AMD/Intel/x64 (access method), version "LI-T3.0.0.31474 Firebird 3.0 Beta 2"
Firebird/Linux/AMD/Intel/x64 (remote server), version "LI-T3.0.0.31474 Firebird 3.0 Beta 2/tcp (oel64)/P13"
Firebird/Linux/AMD/Intel/x64 (remote interface), version "LI-T3.0.0.31474 Firebird 3.0 Beta 2/tcp (oel64)/P13"
on disk structure version 12.0

PS.
No such result in 2.5, get there as expected:

Too many concurrent executions of the same request.
Too many concurrent executions of the same request.
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
....

Commits: 3ca5a7b FirebirdSQL/fbt-repository@9f57cb8

====== Test Details ======

Changed expected_stderr - it became identical in 2.5 & 3.0 since ~07-mar-2015.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

Attachment: gdb-coredump-when-attempt-to-run-infinite-SP-calls.zip [ 12655 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Version: 3.0 Beta 1 [ 10332 ]

Component: Engine [ 10000 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

I cannot reproduce the crash (Ubuntu x64, fresh checkout, tried with both embedded and localhost connections). Looks like a stack overflow before reaching the recursion limit of 1000 nested calls. What ulimit -s returns in your system?

@firebird-automations
Copy link
Collaborator Author

Commented by: @pavel-zotov

$ ulimit -s
8192

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

Same here. Weird.

@firebird-automations
Copy link
Collaborator Author

Commented by: @pavel-zotov

Got new strange results on:

ISQL Version: WI-T3.0.0.31529 Firebird 3.0 Beta 2
Server version:
WI-T3.0.0.31529 Firebird 3.0 Beta 2
WI-T3.0.0.31529 Firebird 3.0 Beta 2/tcp (balaha)/P13
WI-T3.0.0.31529 Firebird 3.0 Beta 2/tcp (balaha)/P13

The following command will cause crash FB for each odd or even runs ( file 'sss.sql' contains single command: select * from p01(1); ):

C:\1INSTALL\FIREBIRD\FB30SNAP>isql -q
SQL> create database 'tmp201501081635.fdb';
SQL> set term ^;
SQL> create or alter procedure p03(a_i int) returns (z int) as
CON> begin
CON> z = 0 ;
CON> suspend;
CON> end^
SQL> commit^
SQL>
SQL> create or alter procedure p02(a_i int) returns (z int) as
CON> begin
CON> z = (select z from p03(:a_i)) + 1;
CON> suspend;
CON> end^
SQL> commit^
SQL>
SQL> create or alter procedure p03(a_i int) returns (z int) as
CON> begin
CON> z = (select z from p02(:a_i)) + 1;
CON> suspend;
CON> end^
SQL> commit^
SQL>
SQL> create or alter procedure p01(a_i int) returns (z int) as
CON> begin
CON> z = (select z from p02(:a_i)) + 1;
CON> suspend;
CON> end^
SQL> commit^
SQL> set term ;^
SQL> exit;

--- run #⁠ 1 ---
C:\1INSTALL\FIREBIRD\FB30SNAP>isql localhost/3333:C:\1INSTALL\FIREBIRD\FB30SNAP\tmp201501081635.fdb -i sss.sql 1>nul
Statement failed, SQLSTATE = HY001
Stack overflow. The resource requirements of the runtime stack have exceeded the memory available to it.
-At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At p...
After line 0 in file sss.sql

--- run #⁠ 2 ---
C:\1INSTALL\FIREBIRD\FB30SNAP>isql localhost/3333:C:\1INSTALL\FIREBIRD\FB30SNAP\tmp201501081635.fdb -i sss.sql 1>nul
Statement failed, SQLSTATE = 08006
Error reading data from the connection.
After line 0 in file sss.sql
Statement failed, SQLSTATE = 08006
Error writing data to the connection.
After line 1 in file sss.sql
Statement failed, SQLSTATE = 08006
Error writing data to the connection.
After line 1 in file sss.sql

--- run #⁠ 3 ---
C:\1INSTALL\FIREBIRD\FB30SNAP>isql localhost/3333:C:\1INSTALL\FIREBIRD\FB30SNAP\tmp201501081635.fdb -i sss.sql 1>nul
Statement failed, SQLSTATE = HY001
Stack overflow. The resource requirements of the runtime stack have exceeded the memory available to it.
-At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At p...
After line 0 in file sss.sql

--- run #⁠ 4 ---
C:\1INSTALL\FIREBIRD\FB30SNAP>isql localhost/3333:C:\1INSTALL\FIREBIRD\FB30SNAP\tmp201501081635.fdb -i sss.sql 1>nul
Statement failed, SQLSTATE = 08006
Error reading data from the connection.
After line 0 in file sss.sql
Statement failed, SQLSTATE = 08006
Error writing data to the connection.
After line 1 in file sss.sql
Statement failed, SQLSTATE = 08006
Error writing data to the connection.
After line 1 in file sss.sql

--- run #⁠ 5 ---
C:\1INSTALL\FIREBIRD\FB30SNAP>isql localhost/3333:C:\1INSTALL\FIREBIRD\FB30SNAP\tmp201501081635.fdb -i sss.sql 1>nul
Statement failed, SQLSTATE = HY001
Stack overflow. The resource requirements of the runtime stack have exceeded the memory available to it.
-At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At p...
After line 0 in file sss.sql

--- run #⁠ 6 ---
C:\1INSTALL\FIREBIRD\FB30SNAP>isql localhost/3333:C:\1INSTALL\FIREBIRD\FB30SNAP\tmp201501081635.fdb -i sss.sql 1>nul
Statement failed, SQLSTATE = 08006
Error reading data from the connection.
After line 0 in file sss.sql
Statement failed, SQLSTATE = 08006
Error writing data to the connection.
After line 1 in file sss.sql
Statement failed, SQLSTATE = 08006
Error writing data to the connection.
After line 1 in file sss.sql

. . . etc . . .

@firebird-automations
Copy link
Collaborator Author

Commented by: @pavel-zotov

One more issue: crash occurs only when FB is started *AS SERVICE* rather than application.
No crashes when FB is launched like this:

C:\1INSTALL\FIREBIRD\FB30SNAP\firebird.exe -a

PS. Checked on: WI-T3.0.0.31532

Image path of service:

C:\1INSTALL\FIREBIRD\FB30SNAP\firebird.exe -s FB_30SS -m -i

@firebird-automations
Copy link
Collaborator Author

Modified by: @hvlad

assignee: Vlad Khorsun [ hvlad ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @hvlad

There are two issues at this ticket:
a) stack overflow exception when it was not happens in previous version of Firebird
b) crash after stack overflow

Issue (a) should be fixed with recent commit (please confirm).
Issue (b) is still investigated and will be moved to its own ticket.

@firebird-automations
Copy link
Collaborator Author

Commented by: @pavel-zotov

> a) stack overflow exception when it was not happens in previous version of Firebird
> Issue (a) should be fixed with recent commit (please confirm).

I see on WI-T3.0.0.31624 that results became like in FB 2.5 and every run of:

SQL> select * from p01(1);

-- now produces only messages about "concurrent executions of the same request", i.e.:

Statement failed, SQLSTATE = 54001
Too many concurrent executions of the same request
-At procedure 'P03' line: 3, col: 3
...
At procedure 'P02' line: 3, col: 3
At procedure 'P03' line: 3, col: 3
At p...

@firebird-automations
Copy link
Collaborator Author

Modified by: @hvlad

Link: This issue is related to CORE4688 [ CORE4688 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @hvlad

Crash after second stack overflow investigated in CORE4688

@firebird-automations
Copy link
Collaborator Author

Modified by: @hvlad

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

resolution: Fixed [ 1 ]

Fix Version: 3.0 Beta 2 [ 10586 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

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

QA Status: Done successfully

Test Details: Changed expected_stderr - it became identical in 2.5 & 3.0 since ~07-mar-2015.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

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

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