drop tables crash
Added by Mark Petryk almost 4 years ago
This is a weird one, I got running dropTables();
[2019-Jun-03 22:57:17.198] 30734 [/staff CNEc6DYxATl8owjH] [warning] "WApplication: WApplication::addMetaHeader() with no effect" select "id", "version", "sysAuthInfo_id", "provider", "identity" from "sysAuthIdentity" where ("sysAuthInfo_id" = $1) and ("provider" = $2) /home/developer/projects/artecams/src/AppStaff.cpp:1536 dropping tables /home/developer/projects/artecams/src/AppStaff.cpp:1540 Thread 7 "artecams" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7fffe27fc700 (LWP 30743)] 0x00007ffff5bc652e in Wt::Dbo::Session::dropTables() () from /opt/Wt4/lib/libwtdbo.so.51 (gdb) bt #0 0x00007ffff5bc652e in Wt::Dbo::Session::dropTables() () from /opt/Wt4/lib/libwtdbo.so.51 #1 0x0000555555d49332 in (anonymous namespace)::AdminWidget::drop_tables (this=0x7fffd00ad270) at /home/developer/projects/artecams/src/AppStaff.cpp:1542 #2 0x0000555555d4bb56 in std::__invoke_impl<void, void ((anonymous namespace)::AdminWidget::*&)(), (anonymous namespace)::AdminWidget*&> (
Here is the code;
1536 std::cout << __FILE__ << ":" << __LINE__ << " dropping tables" << std::endl;· 1537 · 1538 Wt::Dbo::Transaction t(Rtm::AppBase::instance()-> session());· 1539 // Rtm::AppBase::instance()-> session().execute("SET FOREIGN_KEY_CHECKS=0");· 1540 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;· 1541 · 1542 Rtm::AppBase::instance()-> session().dropTables();· 1543 // Rtm::AppBase::instance()-> session().execute("SET FOREIGN_KEY_CHECKS=1");· 1544 · 1545 std::cout << __FILE__ << ":" << __LINE__ << " done: tables dropped" << std::endl;· 1546 ·
Replies (19)
RE: drop tables crash - Added by Roel Standaert almost 4 years ago
I would guess that either Rtm::AppBase::instance() doesn't return a valid pointer, or session() doesn't return a valid session reference?
RE: drop tables crash - Added by Mark Petryk almost 4 years ago
The session() is valid;
/home/developer/projects/artecams/src/AppStaff.cpp:1536 dropping tables SELECT COUNT(1) as col0 FROM "sysUser" /home/developer/projects/artecams/src/AppStaff.cpp:1548 7 /home/developer/projects/artecams/src/AppStaff.cpp:1551 ./doit.sh: line 15: 10394 Segmentation fault (core dumped) ./artecams --config=wt_config.xml --approot="approot" --docroot="docroot;.,/images,/resources,/styles" --errroot="errroot" --http-listen 0.0.0.0:8077 --accesslog=/dev/null
From this code;
1534 void AdminWidget::drop_tables()· 1535 {· 1536 std::cout << __FILE__ << ":" << __LINE__ << " dropping tables" << std::endl;· 1537 · 1538 Wt::Dbo::Transaction t(Rtm::AppBase::instance()-> session());· 1539 auto count =· 1540 Rtm::AppBase::instance()->· 1541 session().query<int>· 1542 (· 1543 "SELECT COUNT(1) FROM \"sysUser\""· 1544 )· 1545 .resultValue()· 1546 ;· 1547 · 1548 std::cout << __FILE__ << ":" << __LINE__ << " " << count << std::endl;· 1549 · 1550 // Rtm::AppBase::instance()-> session().execute("SET FOREIGN_KEY_CHECKS=0");· 1551 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;· 1552 · 1553 Rtm::AppBase::instance()-> session().dropTables();· 1554 // Rtm::AppBase::instance()-> session().execute("SET FOREIGN_KEY_CHECKS=1");· 1555 · 1556 std::cout << __FILE__ << ":" << __LINE__ << " done: tables dropped" << std::endl;· 1557 · 1558 }·
I don't even know what to begin looking at.
RE: drop tables crash - Added by Mark Petryk almost 4 years ago
Here is what I have traced so far;
/home/developer/projects/artecams/src/AppStaff.cpp:1536 dropping tables SELECT COUNT(1) as col0 FROM "sysUser" /home/developer/projects/artecams/src/AppStaff.cpp:1548 7 /home/developer/projects/artecams/src/AppStaff.cpp:1551 /home/serveradmin/projects/wt/src/Wt/Dbo/Session.C:1066 /home/serveradmin/projects/wt/src/Wt/Dbo/Session.C:1070 /home/serveradmin/projects/wt/src/Wt/Dbo/Session.C:1080 ./doit.sh: line 15: 12093 Segmentation fault (core dumped) ./artecams --config=wt_config.xml --approot="approot" --docroot="docroot;.,/images,/resources,/styles" --errroot="errroot" --http-listen 0.0.0.0:8077 --accesslog=/dev/null 1064 void Session::dropTables()· 1065 {· 1066 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;· 1067 · 1068 initSchema();· 1069 · 1070 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;· 1071 · 1072 if (connectionPool_)· 1073 {· 1074 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;· 1075 · 1076 connectionPool_->prepareForDropTables();· 1077 }· 1078 else· 1079 {· 1080 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;· 1081 · 1082 connection_->prepareForDropTables();· 1083 }· 1084 · 1085 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;· 1086 ·
RE: drop tables crash - Added by Roel Standaert almost 4 years ago
So the session doesn't have a valid connection, maybe?
RE: drop tables crash - Added by Mark Petryk almost 4 years ago
What about the "SELECT COUNT (1)..." immediately right above it?
RE: drop tables crash - Added by Roel Standaert almost 4 years ago
Yeah, I guess that the connection does not just disappear in the meantime... It looks like you don't use a debug build of Wt. Using a debug version could help pin down what is going wrong exactly (see the exact line number, check values of variables in the context of the segfault, etc.). So would using valgrind or address sanitizer.
RE: drop tables crash - Added by Roel Standaert almost 4 years ago
Normally you should have a debug build of Wt if you configure it with -DCMAKE_BUILD_TYPE=Debug
, and link with the libwt...d.so
or libwt...d.a
libraries.
RE: drop tables crash - Added by Mark Petryk almost 4 years ago
I don't see too much different here;
/home/developer/projects/artecams/src/AppStaff.cpp:1536 dropping tables SELECT COUNT(1) as col0 FROM "sysUser" /home/developer/projects/artecams/src/AppStaff.cpp:1548 7 /home/developer/projects/artecams/src/AppStaff.cpp:1551 /home/serveradmin/projects/wt/src/Wt/Dbo/Session.C:1066 /home/serveradmin/projects/wt/src/Wt/Dbo/Session.C:1070 /home/serveradmin/projects/wt/src/Wt/Dbo/Session.C:1080 Thread 3 "artecams" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7fffe6832700 (LWP 16573)] 0x00007ffff5ab3a28 in Wt::Dbo::Session::dropTables() () from /opt/Wt4/lib/libwtdbod.so.51 (gdb) bt #0 0x00007ffff5ab3a28 in Wt::Dbo::Session::dropTables() () at /opt/Wt4/lib/libwtdbod.so.51 #1 0x0000555555d4a122 in (anonymous namespace)::AdminWidget::drop_tables() (this=0x7fffd00ad2f0) at /home/developer/projects/artecams/src/AppStaff.cpp:1553 #2 0x0000555555d4c98a in std::__invoke_impl<void, void ((anonymous namespace)::AdminWidget::*&)(), (anonymous namespace)::AdminWidget*&>(std::__invoke_memfun_deref, void ((anonymous namespace)::AdminWidget::*&)((anonymous namespace)::AdminWidget* const), (anonymous namespace)::AdminWidget*&) (__f=@0x7fffd00adba0: (void ((anonymous namespace)::AdminWidget::*)((anonymous namespace)::AdminWidget * const)) 0x555555d49f26 <(anonymous namespace)::AdminWidget::drop_tables()>, __t=@0x7fffd00adbb0: 0x7fffd00ad2f0) at /usr/include/c++/7/bits/invoke.h:73 #3 0x0000555555d4c7aa in std::__invoke<void ((anonymous namespace)::AdminWidget::*&)(), (anonymous namespace)::AdminWidget*&>(void ((anonymous namespace)::AdminWidget::*&)((anonymous namespace)::AdminWidget* const), (anonymous namespace)::AdminWidget*&) (__fn=@0x7fffd00adba0: (void ((anonymous namespace)::AdminWidget::*)((anonymous namespace)::AdminWidget * const)) 0x555555d49f26 <(anonymous namespace)::AdminWidget::drop_tables()>, __args#0=@0x7fffd00adbb0: 0x7fffd00ad2f0) at /usr/include/c++/7/bits/invoke.h:95
With this;
36 target_link_libraries(· 37 artecams· 38 wtd· 39 wthttpd· 40 wtdbod· 41 wtdbosqlite3d· 42 wtdbopostgresd· 43 boost_system· 44 )·
RE: drop tables crash - Added by Mark Petryk almost 4 years ago
It's got to be a problem in my end... I'll re-audit what I've done.
RE: drop tables crash - Added by Roel Standaert almost 4 years ago
That's odd. I'd expect some more info if you really have a debug build of Wt. Is it stripped or something?
RE: drop tables crash - Added by Mark Petryk almost 4 years ago
What do you mean stripped?
I re-compiled wt with the debug option, and then linked to the 'd' library files.
RE: drop tables crash - Added by Roel Standaert almost 4 years ago
Normally that happens if you make install/strip
, or by adding the -s
option. I don't assume you did that, but I'm not sure why you're not getting any more info than the function name and so file.
RE: drop tables crash - Added by Mark Petryk almost 4 years ago
The connection is bad;
/home/developer/projects/artecams/src/AppStaff.cpp:1536 dropping tables SELECT COUNT(1) as col0 FROM "sysUser" /home/developer/projects/artecams/src/AppStaff.cpp:1548 1 /home/developer/projects/artecams/src/AppStaff.cpp:1551 /home/serveradmin/projects/wt/src/Wt/Dbo/Session.C:1066 /home/serveradmin/projects/wt/src/Wt/Dbo/Session.C:1070 /home/serveradmin/projects/wt/src/Wt/Dbo/Session.C:1080 p:0 ./doit.sh: line 15: 28718 Segmentation fault (core dumped) ./artecams --config=wt_config.xml --approot="approot" --docroot="docroot;.,/images,/resources,/styles" --errroot="errroot" --http-listen 0.0.0.0:8077 --accesslog=/dev/null 1064 void Session::dropTables()· 1065 {· 1066 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;· 1067 · 1068 initSchema();· 1069 · 1070 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;· 1071 · 1072 if (connectionPool_)· 1073 {· 1074 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;· 1075 · 1076 connectionPool_->prepareForDropTables();· 1077 }· 1078 else· 1079 {· 1080 std::cout << __FILE__ << ":" << __LINE__ << " p:" << (void*)connection_.get() << std::endl;· 1081 · 1082 connection_->prepareForDropTables();· 1083 }· 1084 · 1085 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;· 1086 ·
So, how could the connection be valid for the query, and be invalid for the drop-tables?
oey!
RE: drop tables crash - Added by lm at almost 4 years ago
The query you ran was select count(1) from ...
? Maybe the driver is really good at optimization and knows the answer without actually connecting to the database?
RE: drop tables crash - Added by Mark Petryk almost 4 years ago
Yikes, that's a heck of a thought! This is just a 'normal' database, not a 'quantum' database, where it knows everything before I ask - lol
I don't know what's going on. The pointer there is clearly empty, perhaps wt should have an assert there... but, it's odd that I can run a query but not that other function.
I'm still exploring.
RE: drop tables crash - Added by Roel Standaert almost 4 years ago
I think I see it. prepareForDropTables()
is directly called on the connection_
, but the connection actually moves to the transaction object (and then moves back to the session when it's done).
This is because dropTables()
is normally done outside of a transaction. I guess it should look at the transaction's connection instead of connection_
there.
In any case, doing dropTables()
outside of a transaction should work.
RE: drop tables crash - Added by Roel Standaert almost 4 years ago
I pushed a commit that should make it possible to do dropTables()
even if there already is an active transaction.