Issue Details (XML | Word | Printable)

Key: CORE-4653
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Vlad Khorsun
Reporter: Pavel Zotov
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Firebird Core

Crash on infinite mutual SP calls (instead of "Too many concurrent executions of the same request.")

Created: 27/Dec/14 06:10 AM   Updated: 23/Sep/15 11:32 AM
Component/s: Engine
Affects Version/s: 3.0 Beta 1
Fix Version/s: 3.0 Beta 2

File Attachments: 1. Zip Archive gdb-coredump-when-attempt-to-run-infinite-SP-calls.zip (1022 kB)

Issue Links:
Relate
 

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


 Description  « Hide
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
....


 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Dmitry Yemanov added a comment - 29/Dec/14 12:17 PM
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?

Pavel Zotov added a comment - 29/Dec/14 12:25 PM
$ ulimit -s
8192

Dmitry Yemanov added a comment - 29/Dec/14 12:36 PM
Same here. Weird.

Pavel Zotov added a comment - 08/Jan/15 01:39 PM
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 . . .

Pavel Zotov added a comment - 08/Jan/15 02:07 PM
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

Vlad Khorsun added a comment - 05/Feb/15 11:09 PM
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.

Pavel Zotov added a comment - 07/Feb/15 11:57 AM
> 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...

Vlad Khorsun added a comment - 10/Feb/15 10:35 AM
Crash after second stack overflow investigated in CORE-4688