Skip to content

DuckDB SIGSEGV when creating table with DEFAULT ? #10008

@SteveLeungYL

Description

@SteveLeungYL

What happens?

The latest release version of DuckDB (v0.9.2 3c695d7ba94d) crashes when executing the following query:

CREATE TABLE t0 ( c1 INT DEFAULT ? );
INSERT INTO t0 VALUES (0);

Here is the Stack Trace from GDB:

(gdb) bt
#0  duckdb::LogicalType::operator== (this=0x28, rhs=...) at /Users/sly/Desktop/Projects/DBMSs/duckdb/duckdb_ori/src/common/types.cpp:1090
#1  0x0000aaaaaaf5f7f0 in duckdb::LogicalType::operator!= (rhs=..., this=<optimized out>)
    at /Users/sly/Desktop/Projects/DBMSs/duckdb/duckdb_ori/src/include/duckdb/common/types.hpp:280
#2  duckdb::PreparedStatementData::RequireRebind (this=<optimized out>, context=..., values=...)
    at /Users/sly/Desktop/Projects/DBMSs/duckdb/duckdb_ori/src/main/prepared_statement_data.cpp:40
#3  0x0000aaaaaaf7350c in duckdb::ClientContext::PendingStatementOrPreparedStatement (this=this@entry=0xaaaaac304030, lock=..., query="INSERT INTO v0 VALUES (0);",
    statement=..., prepared=std::shared_ptr<duckdb::PreparedStatementData> (use count 1, weak count 0) = {...}, parameters=...)
    at /usr/include/c++/9/bits/shared_ptr_base.h:1020
#4  0x0000aaaaaaf74af8 in duckdb::ClientContext::PendingStatementOrPreparedStatementInternal (this=this@entry=0xaaaaac304030, lock=...,
    query="INSERT INTO v0 VALUES (0);", statement=..., prepared=std::shared_ptr<duckdb::PreparedStatementData> (use count 1, weak count 0) = {...}, parameters=...)
    at /usr/include/c++/9/bits/move.h:74
#5  0x0000aaaaaaf74f9c in duckdb::ClientContext::PendingQueryPreparedInternal (this=this@entry=0xaaaaac304030, lock=..., query="INSERT INTO v0 VALUES (0);",
    prepared=std::shared_ptr<duckdb::PreparedStatementData> (use count 1, weak count 0) = {...}, parameters=...) at /usr/include/c++/9/tuple:918
#6  0x0000aaaaaaf75104 in duckdb::ClientContext::PendingQuery (this=0xaaaaac304030, query="INSERT INTO v0 VALUES (0);",
    prepared=std::shared_ptr<duckdb::PreparedStatementData> (use count 1, weak count 0) = {...}, parameters=...)
    at /Users/sly/Desktop/Projects/DBMSs/duckdb/duckdb_ori/src/include/duckdb/common/unique_ptr.hpp:19
#7  0x0000aaaaaaf75370 in duckdb::PreparedStatement::PendingQuery (this=this@entry=0xaaaaac317410, named_values=std::unordered_map with 0 elements,
    allow_stream_result=allow_stream_result@entry=false) at /usr/include/c++/9/bits/shared_ptr_base.h:1020
#8  0x0000aaaaaaf75848 in duckdb::PreparedStatement::PendingQuery (this=0xaaaaac317410, values=..., allow_stream_result=allow_stream_result@entry=false)
    at /Users/sly/Desktop/Projects/DBMSs/duckdb/duckdb_ori/src/main/prepared_statement.cpp:94
#9  0x0000aaaaaaf759a8 in duckdb::PreparedStatement::Execute (this=<optimized out>, values=..., allow_stream_result=allow_stream_result@entry=false)
    at /Users/sly/Desktop/Projects/DBMSs/duckdb/duckdb_ori/src/main/prepared_statement.cpp:81
#10 0x0000aaaaaabb1da4 in duckdb_shell_sqlite3_print_duckbox (pStmt=0xaaaaac30ddc0, max_rows=40, max_width=0, null_value=0xffffffffde7c "", columnar=0)
    at /Users/sly/Desktop/Projects/DBMSs/duckdb/duckdb_ori/src/include/duckdb/common/unique_ptr.hpp:38
#11 0x0000aaaaaab9ecdc in exec_prepared_stmt (pArg=0xffffffffdd68, pStmt=0xaaaaac30ddc0) at /Users/sly/Desktop/Projects/DBMSs/duckdb/duckdb_ori/tools/shell/shell.c:12901
#12 0x0000aaaaaab9fcd4 in shell_exec (pArg=0xffffffffdd68, zSql=<optimized out>, pzErrMsg=<optimized out>)
    at /Users/sly/Desktop/Projects/DBMSs/duckdb/duckdb_ori/tools/shell/shell.c:13236
#13 0x0000aaaaaaba17dc in runOneSqlLine (p=0xffffffffdd68, zSql=0xaaaaac1f6680 "INSERT INTO v0 VALUES (0);", in=0x0, startline=3)
    at /Users/sly/Desktop/Projects/DBMSs/duckdb/duckdb_ori/tools/shell/shell.c:19655
#14 0x0000aaaaaaba8e5c in process_input (p=0xffffffffdd68) at /Users/sly/Desktop/Projects/DBMSs/duckdb/duckdb_ori/tools/shell/shell.c:19773
#15 0x0000aaaaaab8c794 in main (argc=<optimized out>, argv=0xfffffffff0c8) at /Users/sly/Desktop/Projects/DBMSs/duckdb/duckdb_ori/tools/shell/shell.c:20586

This bug is also reproducible on the latest main branch: 24148408432.

To Reproduce

  1. Clone the DuckDB Git from the official repo.
  2. Checkout to either the latest main or release version: v0.9.2 (3c695d7).
  3. Compile the DuckDB binary by using either make reldebug or make debug.
  4. Run the compiled DuckDB and input the following SQL:
CREATE TABLE t0 ( c1 INT DEFAULT ? );
INSERT INTO t0 VALUES (0);
  1. Observe and log the crash information.

OS:

Ubuntu 20.04 LTS

DuckDB Version:

0.9.2

DuckDB Client:

DuckDB official command line client

Full Name:

Yu Liang

Affiliation:

The Pennsylvania State University

Have you tried this on the latest main branch?

I have tested with a main build

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

  • Yes, I have

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions