Issue Details (XML | Word | Printable)

Key: CORE-4419
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Dmitry Yemanov
Reporter: Volker Rehn
Votes: 0
Watchers: 3
Operations

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

Server crashes while sorting records longer than 128KB

Created: 05/May/14 07:27 PM   Updated: 23/Sep/15 11:22 AM
Component/s: Engine
Affects Version/s: 3.0 Alpha 2
Fix Version/s: 3.0 Beta 1

Environment: Win7 64, WI-T3.0.0.31093 Firebird 3.0 Alpha 2 32Bit

QA Status: Done successfully


 Description  « Hide
The following statement crashes the server reliably. It needs a union, 2 joins, a stored function and order by

select u.f1, u.f2
from (select split(line) f1, split(line, 2) f2 from lines1
      union
      select split(line), split(line, 2) from lines2) u
join (select split(line) f1, split(line, 2) f2 from lines1) a on a.f1 = u.f1 and a.f2 = u.f2
join (select split(line) f1, split(line, 2) f2 from lines2) b on b.f1 = u.f1 and b.f2 = u.f2
order by 1, 2

results in

Access violation.
The code attempted to access a virtual address without privilege to do so.
This exception will cause the Firebird server to terminate abnormally.

It works if

1. the order by is omitted
2. one of the joins is omitted or both of them
3. only one split SF is used per select statement instead of two
4. left and substring is used instead of split SF

I could not narrow it down further.


To reproduce, please create two tables and a stored function:

CREATE TABLE LINES1 (
  LINE VARCHAR(2000)
);

INSERT INTO LINES1 (LINE) VALUES('2007 abcabcabc xx');
INSERT INTO LINES1 (LINE) VALUES('2007 defdefdef xx');
INSERT INTO LINES1 (LINE) VALUES('2007 ghighighi xx');
INSERT INTO LINES1 (LINE) VALUES('2008 defdefdef xx');

-- note that spaces between line values should be tabs, \t, ascii_char(9)

COMMIT WORK;

CREATE TABLE LINES2 (
  LINE VARCHAR(2000)
);

INSERT INTO LINES2 (LINE) VALUES('2007 abcabcabc xx');
INSERT INTO LINES2 (LINE) VALUES('2007 defgdefg xx');
INSERT INTO LINES2 (LINE) VALUES('2007 ghighighi xx');
INSERT INTO LINES2 (LINE) VALUES('2008 abcabcabc xx');
INSERT INTO LINES2 (LINE) VALUES('2008 defdefdef xx');

COMMIT WORK;

create function split (
  s varchar(32000),
  n integer = 1
)
returns varchar(32000)
as
declare startpos integer;
declare pos integer;
begin
  -- extract tab separated parts from string
  pos = 0;
  while (n > 0) do
  begin
    startpos = pos + 1;
    pos = position(ascii_char(9), :s, :startpos);
    if (pos = 0) then break;
    n = n - 1;
  end
  if (pos > 0) then
    return nullif(substring(s from :startpos for pos - startpos), '');
  -- get part after last tab
  else if (n = 1) then
    return nullif(substring(s from :startpos), '');
end;

Best regards, Volker

 All   Comments   Change History   Subversion Commits      Sort Order: Descending order - Click to sort in ascending order
There are no comments yet on this issue.