[odb-users] Segfault after adding relations

Boris Kolpackov boris at codesynthesis.com
Thu Sep 29 04:54:17 EDT 2011

Hi Michal,

kontakt at msnoch.pl <kontakt at msnoch.pl> writes:

>         transaction t(db->begin());
>         result start(db->query<Stop>(query::name == p_from ||  
> query::street == p_from));
>         for(result::iterator i(start.begin()); i!= start.end(); ++i)
>         {
>             cout << "Found " << i->test().toStdString() << endl;
>         }
>         t.commit();
>         cout << "Route Done (" << start.size() << ")" << endl;

The only problem that I see is the use of the result object after
the transaction has been committed (last line). Quoting the manual,
Section 4.4, second paragraph:

"The result instance is only usable within the transaction it was
 created in. Trying to manipulate the result after the transaction
 has terminated leads to undefined behavior."

If after fixing this you still get the segfault, I will also need
either the code fragment that persists the Stop/Line objects in the
database or your database dump (if it is big, please send it off-


More information about the odb-users mailing list