Skip to content

Segmentation fault with ROWID and LEFT/RIGHT JOIN #5390

@sankalpgambhir

Description

@sankalpgambhir

What happens?

A segmentation fault occurs when running the attached query. All the offline clients produce a segmentation fault, while https://shell.duckdb.org produces an index out of bounds error.

To Reproduce

Run the following query:

CREATE TABLE t0(c0 INT);
CREATE TABLE t1(c0 INT);
INSERT INTO t0 values (5); -- still occurs if there is no data in the table
INSERT INTO t1 values (4);

SELECT * 
    FROM t1 
    LEFT JOIN t0 ON t1.rowid = t0.rowid
INTERSECT
SELECT * 
    FROM t1 
    LEFT JOIN t0 ON t1.rowid = t0.rowid
    WHERE
        1 BETWEEN -1 AND t1.rowid;          -- error
        -- 1 BETWEEN -1 AND t1.c0;          -- no error
        -- 1 BETWEEN +1 AND t1.rowid;       -- error
        -- 1 BETWEEN 2 AND t1.rowid;        -- no error
        -- false BETWEEN 2 AND t1.rowid;    -- no error
        -- false BETWEEN -1 AND t1.rowid;   -- error
        --  1 == t1.rowid;                  -- error
        -- -1 == t1.rowid;                  -- error

The error varies as shown with the WHERE clauses. We believe the no error cases are just optimized BETWEENs. Further experimentation from our end:

  • Error occurs regardless of data in the table (tested a few cases).
  • Error still occurs on using a RIGHT JOIN, but not when using a JOIN.
  • Error does not occur if we remove the INTERSECT (and the first half).
  • Error still occurs if you have where clauses in both of the intersection halves.
  • Error seems to be focused on rowid, since changing the queries to c0 does not seem to cause an error.

OS:

Linux x86_64

DuckDB Version:

v0.5.1 7c11132 (latest release) / v0.6.0 2213f9c (preview)

DuckDB Client:

CLI / JDBC / Python

Full Name:

Sankalp Gambhir

Affiliation:

École Polytechnique Fédérale de Lausanne

Have you tried this on the latest master branch?

  • I agree

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • I agree

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions