Skip to content

DuckDB SIGSEGV when setting up ill-formed custom type #10141

@SteveLeungYL

Description

@SteveLeungYL

What happens?

In the latest main version of DuckDB (version 6b4f65a) and the released version v0.9.2 (3c695d7), the applications crash when executing the following query sequence:

CREATE TABLE v0 ( c1 INT); 
CREATE TABLE v2 ( c3 INT); 
CREATE TYPE t4 AS UNION ( v0 SETOF t4 ); 
ALTER TABLE v2 ALTER c3 SET DATA TYPE ROW ( c3 t4 ); 

Here is a crash stack trace from version 6b4f65a:

#0  0x000055555588424b in duckdb::CatalogSet::GetEntryDetailed (this=0x55555729dde0, transaction=..., name="main")
    at /home/luy70/Desktop/DBMSs/duckdb/src/catalog/catalog_set.cpp:528
#1  0x0000555555884391 in duckdb::CatalogSet::GetEntry (this=<optimized out>, transaction=..., name="main")
    at /home/luy70/Desktop/DBMSs/duckdb/src/catalog/catalog_set.cpp:551
#2  0x000055555588452f in duckdb::DuckCatalog::GetSchema (this=<optimized out>, transaction=..., schema_name="main", if_not_found=<optimized out>, error_context=...)
    at /home/luy70/Desktop/DBMSs/duckdb/src/include/duckdb/common/unique_ptr.hpp:19
#3  0x000055555587d1be in duckdb::Catalog::TryLookupEntryInternal (this=this@entry=0x55555729b130, transaction=..., type=type@entry=duckdb::CatalogType::TYPE_ENTRY,
    schema="main", name="t4") at /home/luy70/Desktop/DBMSs/duckdb/src/include/duckdb/parser/query_error_context.hpp:21
#4  0x000055555588c1f6 in duckdb::Catalog::TryLookupEntry (this=0x55555729b130, context=..., type=duckdb::CatalogType::TYPE_ENTRY, schema="main", name="t4",
    if_not_found=duckdb::OnEntryNotFound::RETURN_NULL, error_context=...) at /home/luy70/Desktop/DBMSs/duckdb/src/catalog/catalog.cpp:607
#5  0x000055555588c8c2 in duckdb::Catalog::GetEntry (this=0x55555729b130, context=..., type=<optimized out>, schema_name="main", name="t4", if_not_found=<optimized out>,
    error_context=...) at /home/luy70/Desktop/DBMSs/duckdb/src/catalog/catalog.cpp:695
#6  0x000055555588cfb4 in duckdb::Catalog::GetEntry<duckdb::TypeCatalogEntry> (error_context=..., if_not_found=duckdb::OnEntryNotFound::RETURN_NULL, name="t4",
    schema_name="main", context=..., this=<optimized out>) at /home/luy70/Desktop/DBMSs/duckdb/src/include/duckdb/catalog/catalog.hpp:234
#7  duckdb::Catalog::GetType (this=<optimized out>, context=..., schema="main", name="t4", if_not_found=if_not_found@entry=duckdb::OnEntryNotFound::RETURN_NULL)
    at /home/luy70/Desktop/DBMSs/duckdb/src/catalog/catalog.cpp:761
#8  0x0000555555e14aa9 in duckdb::Binder::BindLogicalType (context=..., type=..., catalog=..., schema="main")
    at /home/luy70/Desktop/DBMSs/duckdb/src/include/duckdb/common/optional_ptr.hpp:43
#9  0x0000555555e14958 in duckdb::Binder::BindLogicalType (context=..., type=..., catalog=..., schema="main")
    at /home/luy70/Desktop/DBMSs/duckdb/src/planner/binder/statement/bind_create.cpp:230
#10 0x0000555555e14afb in duckdb::Binder::BindLogicalType (context=..., type=..., catalog=..., schema="main")
    at /home/luy70/Desktop/DBMSs/duckdb/src/planner/binder/statement/bind_create.cpp:258
#11 0x0000555555e14958 in duckdb::Binder::BindLogicalType (context=..., type=..., catalog=..., schema="main")
    at /home/luy70/Desktop/DBMSs/duckdb/src/planner/binder/statement/bind_create.cpp:230
#12 0x0000555555e14afb in duckdb::Binder::BindLogicalType (context=..., type=..., catalog=..., schema="main")
    at /home/luy70/Desktop/DBMSs/duckdb/src/planner/binder/statement/bind_create.cpp:258
#13 0x0000555555e14958 in duckdb::Binder::BindLogicalType (context=..., type=..., catalog=..., schema="main")
    at /home/luy70/Desktop/DBMSs/duckdb/src/planner/binder/statement/bind_create.cpp:230
#14 0x0000555555e14afb in duckdb::Binder::BindLogicalType (context=..., type=..., catalog=..., schema="main")
    at /home/luy70/Desktop/DBMSs/duckdb/src/planner/binder/statement/bind_create.cpp:258
... -- the same function call loop in a huge depth
#23792 0x0000555555e14afb in duckdb::Binder::BindLogicalType (context=..., type=..., catalog=..., schema="main")
    at /home/luy70/Desktop/DBMSs/duckdb/src/planner/binder/statement/bind_create.cpp:258
#23793 0x0000555555e1469b in duckdb::Binder::BindLogicalType (context=..., type=..., catalog=..., schema="main")
    at /home/luy70/Desktop/DBMSs/duckdb/src/planner/binder/statement/bind_create.cpp:214
#23794 0x000055555622b6a7 in duckdb::DuckTableEntry::ChangeColumnType (this=0x5555572aa0a0, context=..., info=...)
    at /home/luy70/Desktop/DBMSs/duckdb/src/include/duckdb/common/optional_ptr.hpp:21
#23795 0x000055555622c540 in duckdb::DuckTableEntry::AlterEntry (this=0x5555572aa0a0, context=..., info=...)
    at /home/luy70/Desktop/DBMSs/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp:192
#23796 0x000055555588e687 in duckdb::CatalogSet::AlterEntry (this=this@entry=0x555557298c08, transaction=..., name="v2", alter_info=...)
    at /home/luy70/Desktop/DBMSs/duckdb/src/include/duckdb/common/optional_ptr.hpp:43
#23797 0x00005555562212e1 in duckdb::DuckSchemaEntry::Alter (this=0x555557298ba0, context=..., info=...)
    at /home/luy70/Desktop/DBMSs/duckdb/src/catalog/catalog_entry/duck_schema_entry.cpp:250
#23798 0x000055555588c780 in duckdb::Catalog::Alter (this=0x55555729b130, context=..., info=...)
    at /home/luy70/Desktop/DBMSs/duckdb/src/include/duckdb/common/optional_ptr.hpp:43
#23799 0x000055555643bc09 in duckdb::PhysicalAlter::GetData (this=0x55555729a530, context=..., chunk=..., input=...)
    at /home/luy70/Desktop/DBMSs/duckdb/src/include/duckdb/common/unique_ptr.hpp:19
#23800 0x0000555555c7dbc0 in duckdb::PipelineExecutor::FetchFromSource (this=0x55555729db30, result=...)
    at /home/luy70/Desktop/DBMSs/duckdb/src/parallel/pipeline_executor.cpp:560
#23801 0x0000555555c82ea3 in duckdb::PipelineExecutor::ExecutePull (this=0x55555729db30, result=...)
    at /home/luy70/Desktop/DBMSs/duckdb/src/parallel/pipeline_executor.cpp:372
#23802 0x0000555555c83021 in duckdb::Executor::FetchChunk (this=0x55555729d5d0) at /usr/include/c++/9/bits/unique_ptr.h:360
#23803 0x0000555555c3fef1 in duckdb::ClientContext::FetchInternal (this=0x5555572995a0, lock=..., executor=..., result=...)
    at /home/luy70/Desktop/DBMSs/duckdb/src/main/client_context.cpp:99
#23804 0x0000555555c4069e in duckdb::ClientContext::FetchResultInternal (this=0x5555572995a0, lock=..., pending=...)
    at /home/luy70/Desktop/DBMSs/duckdb/src/main/client_context.cpp:270
#23805 0x0000555555c41352 in duckdb::PendingQueryResult::ExecuteInternal (this=0x5555572a84a0, lock=...) at /usr/include/c++/9/bits/shared_ptr_base.h:1020
#23806 0x0000555555c41414 in duckdb::PendingQueryResult::Execute (this=0x5555572a84a0) at /home/luy70/Desktop/DBMSs/duckdb/src/include/duckdb/common/unique_ptr.hpp:19
#23807 0x0000555555c43548 in duckdb::PreparedStatement::Execute (this=<optimized out>, values=..., allow_stream_result=allow_stream_result@entry=0x0)
    at /home/luy70/Desktop/DBMSs/duckdb/src/include/duckdb/common/unique_ptr.hpp:38
#23808 0x00005555558401f6 in duckdb_shell_sqlite3_print_duckbox (pStmt=0x5555572aad70, max_rows=0x28, max_width=0x0, null_value=0x7fffffffcbc4 "", columnar=0x0)
    at /home/luy70/Desktop/DBMSs/duckdb/src/include/duckdb/common/unique_ptr.hpp:38
#23809 0x0000555555829afb in exec_prepared_stmt (pArg=0x7fffffffcab0, pStmt=0x5555572aad70) at /home/luy70/Desktop/DBMSs/duckdb/tools/shell/shell.c:12904
#23810 0x000055555582acc5 in shell_exec (pArg=<optimized out>, zSql=<optimized out>, pzErrMsg=0x7fffffffc8a8)
    at /home/luy70/Desktop/DBMSs/duckdb/tools/shell/shell.c:13239
#23811 0x000055555582c9fd in runOneSqlLine (p=0x7fffffffcab0, zSql=0x55555719e740 "ALTER TABLE v2 ALTER c3 SET DATA TYPE ROW ( c3 t4 ); ", in=0x0, startline=0x7)
    at /home/luy70/Desktop/DBMSs/duckdb/tools/shell/shell.c:19658
#23812 0x0000555555835099 in process_input (p=0x7fffffffcab0) at /home/luy70/Desktop/DBMSs/duckdb/tools/shell/shell.c:19776
#23813 0x0000555555815148 in main (argc=argc@entry=0x1, argv=argv@entry=0x7fffffffdde8) at /home/luy70/Desktop/DBMSs/duckdb/tools/shell/shell.c:20594
#23814 0x00007ffff7a6f083 in __libc_start_main (main=0x555555814510 <main>, argc=0x1, argv=0x7fffffffdde8, init=<optimized out>, fini=<optimized out>,
    rtld_fini=<optimized out>, stack_end=0x7fffffffddd8) at ../csu/libc-start.c:308
#23815 0x000055555581879e in _start () at /usr/include/x86_64-linux-gnu/bits/stdio2.h:100

To Reproduce

  1. Clone the DuckDB Git from the official repo.
  2. Checkout to either the latest main or release version: v0.9.2.
  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 v0 ( c1 INT); 
CREATE TABLE v2 ( c3 INT); 
CREATE TYPE t4 AS UNION ( v0 SETOF t4 ); 
ALTER TABLE v2 ALTER c3 SET DATA TYPE ROW ( c3 t4 ); 
  1. Observe and log the crash information.

OS:

Ubuntu 20.04 LTS

DuckDB Version:

v0.9.2

DuckDB Client:

DuckDB official command line host

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