[odb-users] Weird problem/crash with object loading views

Cezan Meyen cezanmeyen at gmail.com
Wed May 29 09:41:03 EDT 2019


Hello there,

I am currently facing a weird problem with the object loading views. After
I found out that the ODB queries only support one level of relationships (
https://www.codesynthesis.com40./pipermail/odb-users/2015-March/0024html) I
tried to implement it with object loading views but this results in "glibc
detected" and a abort.

*The data model:*
Parent3
   ^
   |
Parent2
   ^
   |
Parent1
   ^
   |
Parent
   ^
   |
Child



*View definition:*
#pragma db view object(Child) object(Parent) object(Parent1)
object(Parent2) object(Parent3)
struct relation_object
{
shared_ptr<Child> child;
shared_ptr<Parent1> parent1;
shared_ptr<Parent3> parent3;
};

*Entity defintion:*
All entities are the same except Parent3 which does not contain a parent
field

#pragma db object
struct Child
{
public:

   Child() { }
  //getters and setters
private:
friend class odb::access;
   #pragma db id auto
   int id_;
   std::string name_;
   #pragma db not_null
   shared_ptr<Parent> parent_;

};


*Query:*
{
odb::session s;
typedef odb::query<relation_object> query;
typedef odb::result<relation_object> result;
transaction t (db->begin ());

result r(db->query<relation_object>(query::Parent::name == "parent"));

for (result::iterator i (r.begin ()); i != r.end (); ++i)
{
   cout << "in for "<< std::endl;
   cout << "name: " << i->parent1->name() << endl;
   cout << "name: " << i->parent3->name() << endl;
   cout << "name: " << i->child->name() << endl;
}
t.commit();
}

As can be seen in the output(below) the objects and names are
retrieved/printed correctly but after that the program crashes and aborts.
But when removing object(Parent3) and the shared_ptr from the view it does
not crash and behaves as expected. So is there a maximum of objects that
can be linked to a view or is there something else happening?

Thanks!

Kind regards,
Cezan

*Output:*
in for
name: parent1
name: parent3
name: Main child
*** glibc detected *** ./driver: double free or corruption (fasttop):
0x0000000001d29420 ***
======= Backtrace: =========
/lib64/libc.so.6[0x3224c75f3e]
/lib64/libc.so.6[0x3224c78d8d]
/usr/lib64/libstdc++.so.6(_ZNSsD1Ev+0x39)[0x322f89d4c9]
./driver[0x40976e]
./driver[0x412f1e]
./driver[0x412d1d]
./driver[0x40846c]
./driver[0x40777b]
./driver[0x406a16]
./driver[0x406a56]
./driver[0x409665]
./driver[0x412f50]
./driver[0x412d81]
./driver[0x40846c]
./driver[0x40777b]
./driver[0x406bd6]
./driver[0x406c16]
./driver[0x409559]
./driver[0x412f82]
./driver[0x412de5]
./driver[0x40846c]
./driver[0x40777b]
./driver[0x406d96]
./driver[0x406dd6]
./driver[0x409d8b]
./driver[0x40a7ff]
./driver[0x409e5d]
./driver[0x432511]
./driver[0x407ed7]
./driver[0x405a01]
/lib64/libc.so.6(__libc_start_main+0xfd)[0x3224c1ed1d]
./driver[0x403fe9]
======= Memory map: ========
00400000-00451000 r-xp 00000000 00:69 230886562
 /home/ User /Desktop/ODBExample/driver
00651000-00652000 rw-p 00051000 00:69 230886562
 /home/ User /Desktop/ODBExample/driver
01d09000-01d4b000 rw-p 00000000 00:00 0
 [heap]
3224400000-3224420000 r-xp 00000000 fd:00 792187
/lib64/ld-2.12.so
322461f000-3224621000 r--p 0001f000 fd:00 792187
/lib64/ld-2.12.so
3224621000-3224622000 rw-p 00021000 fd:00 792187
/lib64/ld-2.12.so
3224622000-3224623000 rw-p 00000000 00:00 0
3224800000-3224802000 r-xp 00000000 fd:00 792782
/lib64/libdl-2.12.so
3224802000-3224a02000 ---p 00002000 fd:00 792782
/lib64/libdl-2.12.so
3224a02000-3224a03000 r--p 00002000 fd:00 792782
/lib64/libdl-2.12.so
3224a03000-3224a04000 rw-p 00003000 fd:00 792782
/lib64/libdl-2.12.so
3224c00000-3224d8a000 r-xp 00000000 fd:00 792781
/lib64/libc-2.12.so
3224d8a000-3224f8a000 ---p 0018a000 fd:00 792781
/lib64/libc-2.12.so
3224f8a000-3224f8e000 r--p 0018a000 fd:00 792781
/lib64/libc-2.12.so
3224f8e000-3224f90000 rw-p 0018e000 fd:00 792781
/lib64/libc-2.12.so
3224f90000-3224f94000 rw-p 00000000 00:00 0
3225000000-3225083000 r-xp 00000000 fd:00 792803
/lib64/libm-2.12.so
3225083000-3225282000 ---p 00083000 fd:00 792803
/lib64/libm-2.12.so
3225282000-3225283000 r--p 00082000 fd:00 792803
/lib64/libm-2.12.so
3225283000-3225284000 rw-p 00083000 fd:00 792803
/lib64/libm-2.12.so
3225400000-3225417000 r-xp 00000000 fd:00 792783
/lib64/libpthread-2.12.so
3225417000-3225617000 ---p 00017000 fd:00 792783
/lib64/libpthread-2.12.so
3225617000-3225618000 r--p 00017000 fd:00 792783
/lib64/libpthread-2.12.so
3225618000-3225619000 rw-p 00018000 fd:00 792783
/lib64/libpthread-2.12.so
3225619000-322561d000 rw-p 00000000 00:00 0
322e800000-322e816000 r-xp 00000000 fd:00 792818
/lib64/libgcc_s-4.4.7-20120601.so.1
322e816000-322ea15000 ---p 00016000 fd:00 792818
/lib64/libgcc_s-4.4.7-20120601.so.1
322ea15000-322ea16000 rw-p 00015000 fd:00 792818
/lib64/libgcc_s-4.4.7-20120601.so.1
322f800000-322f8e8000 r-xp 00000000 fd:00 1057699
 /usr/lib64/libstdc++.so.6.0.13
322f8e8000-322fae8000 ---p 000e8000 fd:00 1057699
 /usr/lib64/libstdc++.so.6.0.13
322fae8000-322faef000 r--p 000e8000 fd:00 1057699
 /usr/lib64/libstdc++.so.6.0.13
322faef000-322faf1000 rw-p 000ef000 fd:00 1057699
 /usr/lib64/libstdc++.so.6.0.13
322faf1000-322fb06000 rw-p 00000000 00:00 0
3236800000-323688b000 r-xp 00000000 fd:00 1089402
 /usr/lib64/libsqlite3.so.0.8.6
323688b000-3236a8b000 ---p 0008b000 fd:00 1089402
 /usr/lib64/libsqlite3.so.0.8.6
3236a8b000-3236a8e000 rw-p 0008b000 fd:00 1089402
 /usr/lib64/libsqlite3.so.0.8.6
3236a8e000-3236a8f000 rw-p 00000000 00:00 0
7f58f0000000-7f58f0021000 rw-p 00000000 00:00 0
7f58f0021000-7f58f4000000 ---p 00000000 00:00 0
7f58f63d1000-7f58f63d7000 rw-p 00000000 00:00 0
7f58f63f1000-7f58f63f3000 rw-p 00000000 00:00 0
7f58f63f3000-7f58f6420000 r-xp 00000000 00:69 38217141
/home/ User /ODB2.4.0/SQLite_support_lib/lib/libodb-sqlite-2.4.so
7f58f6420000-7f58f661f000 ---p 0002d000 00:69 38217141
/home/User/ODB2.4.0/SQLite_support_lib/lib/libodb-sqlite-2.4.so
7f58f661f000-7f58f6621000 rw-p 0002c000 00:69 38217141
/home/ User /ODB2.4.0/SQLite_support_lib/lib/libodb-sqlite-2.4.so
7f58f6621000-7f58f6622000 rw-p 00000000 00:00 0
7f58f6622000-7f58f6644000 r-xp 00000000 00:69 113959029
 /home/ User /ODB2.4.0/lib/lib/libodb-2.4.so
7f58f6644000-7f58f6844000 ---p 00022000 00:69 113959029
 /home/ User /ODB2.4.0/lib/lib/libodb-2.4.so
7f58f6844000-7f58f6846000 rw-p 00022000 00:69 113959029
 /home/ User /ODB2.4.0/lib/lib/libodb-2.4.so
7f58f6846000-7f58f6847000 rw-p 00000000 00:00 0
7fff89499000-7fff894af000 rw-p 00000000 00:00 0
 [stack]
7fff895c3000-7fff895c4000 r-xp 00000000 00:00 0
 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0
 [vsyscall]
Abort (core dumped)


More information about the odb-users mailing list