c++c++11wtdbowt-dbo

Wt Segfault on ORM Transaction Commit


http://www.webtoolkit.eu/wt/doc/tutorial/dbo.html says

The complete source code for the examples used in this tutorial are available as ready-to-run programs in the examples/feature/dbo/ folder of Wt.

I'm trying to run tutorial1.C from that directory, and I get the following output:

(gdb) run
Starting program: /home/lawsa/sources/memory/dist/flashcard --docroot . --http-address 0.0.0.0 --http-port 9090
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
begin transaction
create table "user" (
  "id" integer primary key autoincrement,
  "version" integer not null,
  "name" text not null,
  "password" text not null,
  "role" integer not null,
  "karma" integer not null
)
commit transaction
created tables
ending transaction

Program received signal SIGSEGV, Segmentation fault.
0x000000000041a4a8 in void std::vector<Wt::Dbo::ptr_base*, std::allocator<Wt::Dbo::ptr_base*> >::emplace_back<Wt::Dbo::ptr_base*>(Wt::Dbo::ptr_base*&&) ()
(gdb) bt
#0  0x000000000041a4a8 in void std::vector<Wt::Dbo::ptr_base*, std::allocator<Wt::Dbo::ptr_base*> >::emplace_back<Wt::Dbo::ptr_base*>(Wt::Dbo::ptr_base*&&) ()
#1  0x0000000000419c8e in std::vector<Wt::Dbo::ptr_base*, std::allocator<Wt::Dbo::ptr_base*> >::push_back(Wt::Dbo::ptr_base*&&) ()
#2  0x0000000000419682 in void Wt::Dbo::Session::implSave<User>(Wt::Dbo::MetaDbo<User>&) ()
#3  0x0000000000418c4e in Wt::Dbo::MetaDbo<User>::flush() ()
#4  0x00007ffff6c8eae2 in Wt::Dbo::Session::flush() ()
   from /usr/lib/libwtdbo.so.38
#5  0x00007ffff6c9d14d in Wt::Dbo::Transaction::Impl::commit() ()
   from /usr/lib/libwtdbo.so.38
#6  0x00007ffff6c9d1a9 in Wt::Dbo::Transaction::commit() ()
   from /usr/lib/libwtdbo.so.38
#7  0x00000000004063d2 in run() ()
#8  0x0000000000407066 in main ()
(gdb)

For your reference, here's my code: http://sprunge.us/PYSO (I hope that lasts for a while, but let me know if it stops working). And my Makefile: http://sprunge.us/UCge and I ran gdb using $ gdb --args ./flashcard --docroot . --http-address 0.0.0.0 --http-port 9090

You can see the output from line 80 but not from 83, and the backtrace from gdb suggests that line 81 (commit) is the problem. If I remove line 81 so that the transaction commits because of going out of scope, the same problem exists, but it comes from the destructor of transaction.

I'm running archlinux with Wt 3.3.4-4, gcc 5.1.0-5, compiling with -std=c++0x.

The only thing I can imagine is if there is some binary incompatibility with std::vector?


Solution

  • Recompiling Wt should fix the problem. Instead of using the Wt as packaged through archlinux (pacman), compile Wt from source.

    There is perhaps an ABI discrepancy somewhere that should be solved by compiling everything on your own machine with the same standard and boost libraries.