[odb-users] Crash on accessing odb::result object.

Mike O'Driscoll modriscoll at clearpathrobotics.com
Thu Jul 16 18:39:54 EDT 2015


Hello Users,

I'm in the process of evaluating the ODB libraries using Postgresql and
encountering the following crash after getting results from a query.

If I only instantiate "r" and don't provide it a query result everything
works fine.
Although if I call "db_->query" and act upon the results, I get a segfault
on empty or trying to work with the iterator.

I've tried to follow the examples as closely as possible but continue to be
unable to progress.
Any thoughts or insights would be appriciated.

GDB backtrace:

Program received signal SIGSEGV, Segmentation fault.

#0  0x00007ffff416a4a0 in odb::pgsql::select_statement::next() ()
>    from /usr/lib/x86_64-linux-gnu/libodb-pgsql-2.4.so
> #1  0x00007ffff6bb9edc in
> odb::pgsql::object_result_impl<mytype::orm::Task>::next (this=0x65cb10) at
> /usr/include/odb/pgsql/simple-object-result.txx:102
> #2  0x00007ffff6bb291a in begin (this=0x65cb10)
>     at /usr/include/odb/simple-object-result.hxx:76
> #3  empty (this=0x7fffffffc720) at /usr/include/odb/result.hxx:200
> #4  mytype::orm::MyORM::getUncompletedTasks (this=0x64f610)
>     at /path/to/my_orm.cpp:107



Code:

  odb::core::transaction t(db_->begin());
>   odb::core::query<mytype::orm::Task> q_rt;
>   q_rt = odb::core::query<mytype::orm::Task>(
>     odb::core::query<mytype::orm::Task>::task_state
> != mytype::orm::COMPLETED);
>   ROS_INFO("ORM: Querying for uncompleted tasks");
>   // Transact the database and query it.
>   odb::core::result<mytype::orm::Taskt> r =
>           db_->query<mytype::orm::Task>(q_rt);
>   t.commit();
>   ROS_INFO("ORM: Processing results, count: %d", r.size());
>   // Take all results and push them to a results vector
>   if (!r.empty())
>   {
>     for (odb::result<mytype::orm::Taskt>::iterator i = r.begin();
>          i != r.end();
>          ++i)
>     {
>       ROS_INFO("ORM: Processing Loop");
>       // non_complete_tasks.push_back(i->task());
>     }
>   }
>   ROS_INFO("ORM: Found %d, uncompleted tasks", non_complete_tasks.size());



--
Mike O'Driscoll


More information about the odb-users mailing list