Skip to content

DuckDB crashes when no columns are available for RETURNING clause #10139

@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 ); 
INSERT INTO v0 BY POSITION ( SELECT TRUE ) OFFSET 1 ROWS RETURNING v0 . * EXCLUDE c1 ; 

Here is a crash stack trace from version 6b4f65a:

#0  __GI_raise (sig=sig@entry=0x6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff7a6d859 in __GI_abort () at abort.c:79
#2  0x00007ffff7e458d1 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff7e5137c in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff7e513e7 in std::terminate() () from /lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff7e51699 in __cxa_throw () from /lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x000055555585ff94 in duckdb::vector<unsigned long, true>::AssertIndexInBounds (index=0x0, size=0x0) at /usr/include/c++/9/ext/new_allocator.h:89
#7  0x00005555559fc2f6 in duckdb::vector<unsigned long, true>::get<true> (__n=0x0, this=0x7fffffffbb40)
    at /home/luy70/Desktop/DBMSs/duckdb/src/include/duckdb/common/vector.hpp:75
#8  duckdb::vector<unsigned long, true>::operator[] (__n=0x0, this=0x7fffffffbb40) at /home/luy70/Desktop/DBMSs/duckdb/src/include/duckdb/common/vector.hpp:76
#9  duckdb::BoxRenderer::ComputeRenderWidths (this=0x7fffffffc4a0, names=..., result_types=..., Python Exception <class 'AttributeError'> 'NoneType' object has no attribute 'pointer':
collections=std::__cxx11::list, min_width=0xa, max_width=0xab,
    column_map=..., total_length=@0x7fffffffbe38: 0x1) at /home/luy70/Desktop/DBMSs/duckdb/src/common/box_renderer.cpp:318
#10 0x0000555555a094b6 in duckdb::BoxRenderer::Render (this=0x7fffffffc4a0, context=..., names=..., result=..., ss=...)
    at /home/luy70/Desktop/DBMSs/duckdb/src/common/box_renderer.cpp:698
#11 0x0000555555a0a366 in duckdb::BoxRenderer::ToString (this=this@entry=0x7fffffffc4a0, context=..., names=..., result=...)
    at /home/luy70/Desktop/DBMSs/duckdb/src/common/box_renderer.cpp:19
#12 0x00005555558405fb in duckdb_shell_sqlite3_print_duckbox (pStmt=0x55555729a430, max_rows=<optimized out>, max_width=0x0, null_value=<optimized out>, columnar=0x0)
    at /usr/include/c++/9/bits/shared_ptr_base.h:1020
#13 0x0000555555829afb in exec_prepared_stmt (pArg=0x7fffffffcab0, pStmt=0x55555729a430) at /home/luy70/Desktop/DBMSs/duckdb/tools/shell/shell.c:12904
#14 0x000055555582acc5 in shell_exec (pArg=<optimized out>, zSql=<optimized out>, pzErrMsg=0x7fffffffc8a8) at /home/luy70/Desktop/DBMSs/duckdb/tools/shell/shell.c:13239
#15 0x000055555582c9fd in runOneSqlLine (p=0x7fffffffcab0, zSql=0x55555719e740 "INSERT INTO v0 BY POSITION ( SELECT TRUE ) OFFSET 1 ROWS RETURNING v0 . * EXCLUDE c1 ; ",
    in=0x0, startline=0x3) at /home/luy70/Desktop/DBMSs/duckdb/tools/shell/shell.c:19658
#16 0x0000555555835099 in process_input (p=0x7fffffffcab0) at /home/luy70/Desktop/DBMSs/duckdb/tools/shell/shell.c:19776
#17 0x0000555555815148 in main (argc=argc@entry=0x1, argv=argv@entry=0x7fffffffdde8) at /home/luy70/Desktop/DBMSs/duckdb/tools/shell/shell.c:20594
#18 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
#19 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 ); 
INSERT INTO v0 BY POSITION ( SELECT TRUE ) OFFSET 1 ROWS RETURNING v0 . * EXCLUDE c1 ; 
  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