This repository was archived by the owner on Sep 27, 2019. It is now read-only.
This repository was archived by the owner on Sep 27, 2019. It is now read-only.
Crash in Parser when using COPY without options #1405
Open
Description
COPY
got introduced in #1371, including parser changes. Not explicitly specifying a delimiter however crashes Peloton in the parser.
Example from @lmwnshn:
postgres=# COPY customer FROM '/Users/wanshenl/Desktop/data/tpch1/customer.tbl';
Peloton output with stack trace
2018-06-12 16:46:27 [src/network/peloton_server.cpp:267:SetupServer] INFO - Listening on port 15721
2018-06-12 16:46:29 [src/network/connection_dispatcher_task.cpp:63:DispatchConnection] DEBUG - Dispatching connection to worker 0
2018-06-12 16:46:29 [src/network/postgres_protocol_handler.cpp:1007:ProcessInitialPacket] INFO - protocol version: 80877103
2018-06-12 16:46:29 [src/network/postgres_protocol_handler.cpp:1007:ProcessInitialPacket] INFO - protocol version: 196608
Process 16764 stopped
* thread #12, stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
frame #0: 0x000000010188624d libpeloton-d.0.0.5.dylib`peloton::parser::PostgresParser::CopyTransform(root=0x0000625000085098) at postgresparser.cpp:1529
1526
1527 // Handle options
1528 ListCell *cell = nullptr;
-> 1529 for_each_cell(cell, root->options->head) {
1530 auto *def_elem = reinterpret_cast<DefElem *>(cell->data.ptr_value);
1531
1532 // Check delimiter
Target 0: (peloton) stopped.
(lldb) bt
warning: could not execute support code to read Objective-C class data in the process. This may reduce the quality of type information available.
* thread #12, stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
* frame #0: 0x000000010188624d libpeloton-d.0.0.5.dylib`peloton::parser::PostgresParser::CopyTransform(root=0x0000625000085098) at postgresparser.cpp:1529
frame #1: 0x000000010188553d libpeloton-d.0.0.5.dylib`peloton::parser::PostgresParser::NodeTransform(stmt=0x0000625000085098) at postgresparser.cpp:1877
frame #2: 0x000000010188f949 libpeloton-d.0.0.5.dylib`peloton::parser::PostgresParser::ListTransform(root=0x0000625000085108) at postgresparser.cpp:1907
frame #3: 0x0000000101892ddb libpeloton-d.0.0.5.dylib`peloton::parser::PostgresParser::ParseSQLString(text="COPY customer FROM '/Users/wanshenl/Desktop/data/tpch1/customer.tbl';") at postgresparser.cpp:1985
frame #4: 0x0000000101893291 libpeloton-d.0.0.5.dylib`peloton::parser::PostgresParser::ParseSQLString(sql="COPY customer FROM '/Users/wanshenl/Desktop/data/tpch1/customer.tbl';") at postgresparser.cpp:1999
frame #5: 0x0000000101893471 libpeloton-d.0.0.5.dylib`peloton::parser::PostgresParser::BuildParseTree(this=0x00000001032afb80, query_string="COPY customer FROM '/Users/wanshenl/Desktop/data/tpch1/customer.tbl';") at postgresparser.cpp:2009
frame #6: 0x00000001013089a6 libpeloton-d.0.0.5.dylib`peloton::network::PostgresProtocolHandler::ExecQueryMessage(this=0x000061900034fd80, pkt=0x000061900034fda8, thread_id=0) at postgres_protocol_handler.cpp:120
frame #7: 0x000000010135d85b libpeloton-d.0.0.5.dylib`peloton::network::PostgresProtocolHandler::ProcessNormalPacket(this=0x000061900034fd80, pkt=0x000061900034fda8, thread_id=0) at postgres_protocol_handler.cpp:1089
frame #8: 0x000000010135d77a libpeloton-d.0.0.5.dylib`peloton::network::PostgresProtocolHandler::Process(this=0x000061900034fd80, rbuf=0x000060700006a7d8, thread_id=0) at postgres_protocol_handler.cpp:1071
frame #9: 0x00000001012aa6e5 libpeloton-d.0.0.5.dylib`peloton::network::ConnectionHandle::Process(this=0x0000613000120000) at connection_handle.cpp:655
frame #10: 0x00000001012ab1e9 libpeloton-d.0.0.5.dylib`peloton::network::ConnectionHandle::StateMachine::Delta_(this=0x00007000079f5808, w=0x0000613000120000)::$_1::operator()(peloton::network::ConnectionHandle&) const at connection_handle.cpp:91
frame #11: 0x00000001012ab1c8 libpeloton-d.0.0.5.dylib`peloton::network::ConnectionHandle::StateMachine::Delta_(w=0x0000613000120000)::$_1::__invoke(peloton::network::ConnectionHandle&) at connection_handle.cpp:91
frame #12: 0x000000010129c842 libpeloton-d.0.0.5.dylib`peloton::network::ConnectionHandle::StateMachine::Accept(this=0x0000613000120174, action=WAKEUP, connection=0x0000613000120000) at connection_handle.cpp:134
frame #13: 0x00000001012aafcb libpeloton-d.0.0.5.dylib`peloton::network::ConnectionHandle::HandleEvent(this=0x0000613000120000, (null)=27, (null)=2) at connection_handle.h:71
frame #14: 0x00000001012ab11d libpeloton-d.0.0.5.dylib`peloton::network::ConnectionHandle::UpdateEventFlags(this=0x0000100000000000, fd=27, flags=2, arg=0x0000613000120000)::$_21::operator()(int, short, void*) const at connection_handle.cpp:178
frame #15: 0x00000001012ab0e8 libpeloton-d.0.0.5.dylib`peloton::network::ConnectionHandle::UpdateEventFlags(fd=27, flags=2, arg=0x0000613000120000)::$_21::__invoke(int, short, void*) at connection_handle.cpp:178
frame #16: 0x000000010ad8e94f libevent-2.0.5.dylib`event_base_loop + 1871
frame #17: 0x000000010000f8d5 peloton`peloton::EventUtil::EventBaseDispatch(base=0x0000000beaf94280) at event_util.h:81
frame #18: 0x000000010000f8aa peloton`peloton::NotifiableTask::EventLoop(this=0x000060b00002f968) at notifiable_task.h:176
frame #19: 0x0000000101298e71 libpeloton-d.0.0.5.dylib`peloton::network::ConnectionDispatcherTask::ConnectionDispatcherTask(this=0x0000603000747a08)::$_2::operator()() const at connection_dispatcher_task.cpp:43
frame #20: 0x00000001012985ee libpeloton-d.0.0.5.dylib`void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, peloton::network::ConnectionDispatcherTask::ConnectionDispatcherTask(int, int)::$_2> >(void*) [inlined] decltype(__f=0x0000603000747a08)::$_2>(fp)(std::__1::forward<>(fp0))) std::__1::__invoke<peloton::network::ConnectionDispatcherTask::ConnectionDispatcherTask(int, int)::$_2>(peloton::network::ConnectionDispatcherTask::ConnectionDispatcherTask(int, int)::$_2&&) at type_traits:4323
frame #21: 0x00000001012985d4 libpeloton-d.0.0.5.dylib`void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, peloton::network::ConnectionDispatcherTask::ConnectionDispatcherTask(int, int)::$_2> >(void*) [inlined] void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, peloton::network::ConnectionDispatcherTask::ConnectionDispatcherTask(int, int)::$_2>(__t=0x0000603000747a00)::$_2>&, std::__1::__tuple_indices<>) at thread:342
frame #22: 0x0000000101298598 libpeloton-d.0.0.5.dylib`void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, peloton::network::ConnectionDispatcherTask::ConnectionDispatcherTask(int, int)::$_2> >(__vp=0x0000603000747a00) at thread:352
frame #23: 0x00007fff584fe661 libsystem_pthread.dylib`_pthread_body + 340
frame #24: 0x00007fff584fe50d libsystem_pthread.dylib`_pthread_start + 377
frame #25: 0x00007fff584fdbf9 libsystem_pthread.dylib`thread_start + 13
* thread #12, stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
* frame #0: 0x000000010188624d libpeloton-d.0.0.5.dylib`peloton::parser::PostgresParser::CopyTransform(root=0x0000625000085098) at postgresparser.cpp:1529
frame #1: 0x000000010188553d libpeloton-d.0.0.5.dylib`peloton::parser::PostgresParser::NodeTransform(stmt=0x0000625000085098) at postgresparser.cpp:1877
frame #2: 0x000000010188f949 libpeloton-d.0.0.5.dylib`peloton::parser::PostgresParser::ListTransform(root=0x0000625000085108) at postgresparser.cpp:1907
frame #3: 0x0000000101892ddb libpeloton-d.0.0.5.dylib`peloton::parser::PostgresParser::ParseSQLString(text="COPY customer FROM '/Users/wanshenl/Desktop/data/tpch1/customer.tbl';") at postgresparser.cpp:1985
frame #4: 0x0000000101893291 libpeloton-d.0.0.5.dylib`peloton::parser::PostgresParser::ParseSQLString(sql="COPY customer FROM '/Users/wanshenl/Desktop/data/tpch1/customer.tbl';") at postgresparser.cpp:1999
frame #5: 0x0000000101893471 libpeloton-d.0.0.5.dylib`peloton::parser::PostgresParser::BuildParseTree(this=0x00000001032afb80, query_string="COPY customer FROM '/Users/wanshenl/Desktop/data/tpch1/customer.tbl';") at postgresparser.cpp:2009
frame #6: 0x00000001013089a6 libpeloton-d.0.0.5.dylib`peloton::network::PostgresProtocolHandler::ExecQueryMessage(this=0x000061900034fd80, pkt=0x000061900034fda8, thread_id=0) at postgres_protocol_handler.cpp:120
frame #7: 0x000000010135d85b libpeloton-d.0.0.5.dylib`peloton::network::PostgresProtocolHandler::ProcessNormalPacket(this=0x000061900034fd80, pkt=0x000061900034fda8, thread_id=0) at postgres_protocol_handler.cpp:1089
frame #8: 0x000000010135d77a libpeloton-d.0.0.5.dylib`peloton::network::PostgresProtocolHandler::Process(this=0x000061900034fd80, rbuf=0x000060700006a7d8, thread_id=0) at postgres_protocol_handler.cpp:1071
frame #9: 0x00000001012aa6e5 libpeloton-d.0.0.5.dylib`peloton::network::ConnectionHandle::Process(this=0x0000613000120000) at connection_handle.cpp:655
frame #10: 0x00000001012ab1e9 libpeloton-d.0.0.5.dylib`peloton::network::ConnectionHandle::StateMachine::Delta_(this=0x00007000079f5808, w=0x0000613000120000)::$_1::operator()(peloton::network::ConnectionHandle&) const at connection_handle.cpp:91
frame #11: 0x00000001012ab1c8 libpeloton-d.0.0.5.dylib`peloton::network::ConnectionHandle::StateMachine::Delta_(w=0x0000613000120000)::$_1::__invoke(peloton::network::ConnectionHandle&) at connection_handle.cpp:91
frame #12: 0x000000010129c842 libpeloton-d.0.0.5.dylib`peloton::network::ConnectionHandle::StateMachine::Accept(this=0x0000613000120174, action=WAKEUP, connection=0x0000613000120000) at connection_handle.cpp:134
frame #13: 0x00000001012aafcb libpeloton-d.0.0.5.dylib`peloton::network::ConnectionHandle::HandleEvent(this=0x0000613000120000, (null)=27, (null)=2) at connection_handle.h:71
frame #14: 0x00000001012ab11d libpeloton-d.0.0.5.dylib`peloton::network::ConnectionHandle::UpdateEventFlags(this=0x0000100000000000, fd=27, flags=2, arg=0x0000613000120000)::$_21::operator()(int, short, void*) const at connection_handle.cpp:178
frame #15: 0x00000001012ab0e8 libpeloton-d.0.0.5.dylib`peloton::network::ConnectionHandle::UpdateEventFlags(fd=27, flags=2, arg=0x0000613000120000)::$_21::__invoke(int, short, void*) at connection_handle.cpp:178
frame #16: 0x000000010ad8e94f libevent-2.0.5.dylib`event_base_loop + 1871
frame #17: 0x000000010000f8d5 peloton`peloton::EventUtil::EventBaseDispatch(base=0x0000000beaf94280) at event_util.h:81
frame #18: 0x000000010000f8aa peloton`peloton::NotifiableTask::EventLoop(this=0x000060b00002f968) at notifiable_task.h:176
frame #19: 0x0000000101298e71 libpeloton-d.0.0.5.dylib`peloton::network::ConnectionDispatcherTask::ConnectionDispatcherTask(this=0x0000603000747a08)::$_2::operator()() const at connection_dispatcher_task.cpp:43
frame #20: 0x00000001012985ee libpeloton-d.0.0.5.dylib`void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, peloton::network::ConnectionDispatcherTask::ConnectionDispatcherTask(int, int)::$_2> >(void*) [inlined] decltype(__f=0x0000603000747a08)::$_2>(fp)(std::__1::forward<>(fp0))) std::__1::__invoke<peloton::network::ConnectionDispatcherTask::ConnectionDispatcherTask(int, int)::$_2>(peloton::network::ConnectionDispatcherTask::ConnectionDispatcherTask(int, int)::$_2&&) at type_traits:4323
frame #21: 0x00000001012985d4 libpeloton-d.0.0.5.dylib`void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, peloton::network::ConnectionDispatcherTask::ConnectionDispatcherTask(int, int)::$_2> >(void*) [inlined] void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, peloton::network::ConnectionDispatcherTask::ConnectionDispatcherTask(int, int)::$_2>(__t=0x0000603000747a00)::$_2>&, std::__1::__tuple_indices<>) at thread:342
frame #22: 0x0000000101298598 libpeloton-d.0.0.5.dylib`void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, peloton::network::ConnectionDispatcherTask::ConnectionDispatcherTask(int, int)::$_2> >(__vp=0x0000603000747a00) at thread:352
frame #23: 0x00007fff584fe661 libsystem_pthread.dylib`_pthread_body + 340
frame #24: 0x00007fff584fe50d libsystem_pthread.dylib`_pthread_start + 377
frame #25: 0x00007fff584fdbf9 libsystem_pthread.dylib`thread_start + 13