Project

General

Profile

Connecting Form Widgets to the database

Added by Jeremy Minton almost 12 years ago

I am a little unclear about the persistence/transience of objects representing database entries so I am not entirely sure how to ask this.

Essentially what I have done is to write a library of form widgets that are connected to functions that synchronise the current values with the database. The latest is to transfer names between two lists to handle manyToOne and manyToMany relations. I use a boost function to bind a database session and function to start a transaction then change the appropriate collection. The program compiles and runs but when the widget is used a fatal Wt error occurs and the session is restarted. This error is presented:

[2012-Dec-15 10:55:01.287464] 6379 [/ uHZ3QJKPXRe4Tvvj] [error] "Wt: error during event handling: Wt::Dbo::ptr: null dereference"
[2012-Dec-15 10:55:01.287523] 6379 [/ uHZ3QJKPXRe4Tvvj] [error] "Wt: fatal error: Wt::Dbo::ptr: null dereference"

I have isolated the error to the boost function described above but am unsure why this is occurring.

Any pointers would be appreciated.


Replies (6)

RE: Connecting Form Widgets to the database - Added by Wim Dumon almost 12 years ago

Hi Jeremy,

Any chance that you could give us a small, complete example that demonstrates what you do to get this problem?

Thank you,

Wim.

RE: Connecting Form Widgets to the database - Added by Jeremy Minton almost 12 years ago

Unfortunately not. I constructed a simpler test example when I was writing the code and this works fine.

I've been chasing this problem some more and I now get a segmentation fault but only when I run it on my desktop (64bit) but not my laptop (32bit).

I am happy to provide the complete code or anything else that could be of use but I am at a bit of a lose as far as where to even look for the problem.

Any advice about how to go about diagnosing this or reporting a bug in the 64bit version (if that's what it is) would be greatly appreciated.

Thanks for any help,

Jeremy

s.

Sorry for the slow reply - Christmas holiday as well as being distracted with some other projects/things I'll actually get paid for.

RE: Connecting Form Widgets to the database - Added by Koen Deforche almost 12 years ago

Hey,

On what platform are you working?

W.r.t. the original problem, you could catch the throw of the exception in the debugger to investigate the source of it ?

Regards,

koen

RE: Connecting Form Widgets to the database - Added by Jeremy Minton almost 12 years ago

Thanks Koen,

I did what you suggested as well as adding a great deal of logging which allowed me to isolate it to the particular line. Unfortunately I can't find where the fault is arrising - particularly as it is not arising on my laptop.

I am running Ubuntu 12.10, Wt 3.2.3 and Boost 1.49.

The Wt-db library reports "begin transaction" but does not end the transaction.

Using backtrace I get:

#0  0x00007ffff6007838 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1  0x00007ffff6c674a7 in Wt::Dbo::backend::Sqlite3Statement::Sqlite3Statement (this=0x7fffe00038d0, db=..., sql=...)
    at /home/jeremy/Wt/wt-3.2.3/src/Wt/Dbo/backend/Sqlite3.C:37
#2  0x00007ffff6c65aa4 in Wt::Dbo::backend::Sqlite3::prepareStatement (this=0x7fffcc008df8, sql=...)
    at /home/jeremy/Wt/wt-3.2.3/src/Wt/Dbo/backend/Sqlite3.C:558
#3  0x00007ffff6a2a6af in Wt::Dbo::Session::prepareStatement (this=<optimised out>, id=..., sql=...)
    at /home/jeremy/Wt/wt-3.2.3/src/Wt/Dbo/Session.C:1038
#4  0x000000000043148d in Wt::Dbo::SqlStatement* Wt::Dbo::Session::getStatement<Client>(int) ()
#5  0x000000000043a3d8 in Wt::Dbo::SaveDbAction<Client>::visit(Client&) ()
#6  0x00000000004390c1 in void Wt::Dbo::Session::implSave<Client>(Wt::Dbo::MetaDbo<Client>&) ()
#7  0x00000000004383e6 in Wt::Dbo::MetaDbo<Client>::flush() ()
#8  0x00007ffff6a2a4c2 in Wt::Dbo::Session::flush (this=0x7fffcc008d20) at /home/jeremy/Wt/wt-3.2.3/src/Wt/Dbo/Session.C:982
#9  0x00007ffff6a36ba3 in Wt::Dbo::Transaction::Impl::commit (this=0x7fffe0003840)
    at /home/jeremy/Wt/wt-3.2.3/src/Wt/Dbo/Transaction.C:124
#10 0x00007ffff6a36c75 in Wt::Dbo::Transaction::commit (this=0x7ffff0d75790)
    at /home/jeremy/Wt/wt-3.2.3/src/Wt/Dbo/Transaction.C:83
#11 0x0000000000450b65 in makePages::detailClient::updateWidget(Wt::Dbo::ptr<Client>) ()
#12 0x000000000046c6a4 in boost::_mfi::mf1<void, makePages::detailClient, Wt::Dbo::ptr<Client> >::operator()(makePages::detailClient*, Wt::Dbo::ptr<Client>) const ()
#13 0x000000000046bab1 in void boost::_bi::list2<boost::_bi::value<makePages::detailClient*>, boost::arg<1> >::operator()<boost::_mfi::mf1<void, makePages::detailClient, Wt::Dbo::ptr<Client> >, boost::_bi::list6<Wt::Dbo::ptr<Client>&, Wt::NoClass&, Wt::NoClass&, Wt::NoClass&, Wt::NoClass&, Wt::NoClass&> >(boost::_bi::type<void>, boost::_mfi::mf1<void, makePages::detailClient, Wt::Dbo::ptr<Client> >&, boost::_bi::list6<Wt::Dbo::ptr<Client>&, Wt::NoClass&, Wt::NoClass&, Wt::NoClass&, Wt::NoClass&, Wt::NoClass&>&, int) ()
#14 0x000000000046b1e9 in void boost::_bi::bind_t<void, boost::_mfi::mf1<void, makePages::detailClient, Wt::Dbo::ptr<Client> >, boost::_bi::list2<boost::_bi::value<makePages::detailClient*>, boost::arg<1> > >::operator()<Wt::Dbo::ptr<Client>, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass>(Wt::Dbo::ptr<Client>&, Wt::NoClass&, Wt::NoClass&, Wt::NoClass&, Wt::NoClass&, Wt::NoClass&) ()
#15 0x000000000046a3f0 in boost::detail::function::void_function_obj_invoker6<boost::_bi::bind_t<void, boost::_mfi::mf1<void, makePages::detailClient, Wt::Dbo::ptr<Client> >, boost::_bi::list2<boost::_bi::value<makePages::detailClient*>, boost::arg<1> > >, void, Wt::Dbo::ptr<Client>, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass>::invoke(boost::detail::function::function_buffer&, Wt::Dbo::ptr<Client>, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass) ()
#16 0x0000000000435267 in boost::function6<void, Wt::Dbo::ptr<Client>, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass>::operator()(Wt::Dbo::ptr<Client>, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass) const ()
#17 0x00000000004345fc in boost::signals::detail::unusable boost::signals::detail::call_bound6<void>::caller<Wt::Dbo::ptr<Client>, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass, boost::function6<void, Wt::Dbo::ptr<Client>, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass> >::operator()<boost::signals::detail::connection_slot_pair>(boost::signals::detail::connection_slot_pair const&) const ()
#18 0x0000000000433402 in boost::signals::detail::slot_call_iterator<boost::signals::detail::call_bound6<void>::caller<Wt::Dbo::ptr<Client>, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass, boost::function6<void, Wt::Dbo::ptr<Client>, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass, Wt::NoClass> >, boost::signals::detail::named_slot_map_iterator>::dereference() const ()

Thanks for the help,

Jeremy

RE: Connecting Form Widgets to the database - Added by Koen Deforche almost 12 years ago

Hey,

W.r.t. backtrace: what was the break point ? Or was it stopped because of a SIGSEGV signal ? It doesn't seem to be an exception thrown since it doesn't start with the throw() function. Could you include more gdb context ?

It points to a copyconstructor for std::string in the constructor of Sqlite3Statement --- that is quite suspect, and if I were to encounter this, my first idea would be to check my build is sane: do a full clean build of Wt and my application, and check that there is no header files / library versions mix-up.

Also, does valgrind report any problem ?

Regards,

koen

RE: Connecting Form Widgets to the database - Added by Jeremy Minton almost 12 years ago

It stopped because of segmentation fault. I simply ran the program in gdb before backtracing the failure.

I will do a Wt reinstall and failing that I'll run valgrind and get back to you.

Thanks,

    (1-6/6)