{"action":"created","issue":{"url":"https://api.github.com/repos/SRombauts/SQLiteCpp/issues/48","labels_url":"https://api.github.com/repos/SRombauts/SQLiteCpp/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/SRombauts/SQLiteCpp/issues/48/comments","events_url":"https://api.github.com/repos/SRombauts/SQLiteCpp/issues/48/events","html_url":"https://github.com/SRombauts/SQLiteCpp/issues/48","id":73412145,"number":48,"title":"Memory error in destructor","user":{"login":"onuraslan","id":345828,"avatar_url":"https://avatars.githubusercontent.com/u/345828?v=3","gravatar_id":"","url":"https://api.github.com/users/onuraslan","html_url":"https://github.com/onuraslan","followers_url":"https://api.github.com/users/onuraslan/followers","following_url":"https://api.github.com/users/onuraslan/following{/other_user}","gists_url":"https://api.github.com/users/onuraslan/gists{/gist_id}","starred_url":"https://api.github.com/users/onuraslan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onuraslan/subscriptions","organizations_url":"https://api.github.com/users/onuraslan/orgs","repos_url":"https://api.github.com/users/onuraslan/repos","events_url":"https://api.github.com/users/onuraslan/events{/privacy}","received_events_url":"https://api.github.com/users/onuraslan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-05T19:40:02Z","updated_at":"2015-05-05T20:48:12Z","closed_at":null,"body":"I started to play with SQLiteCpp. I have a simple program:\r\n\r\n    #include \"SQLiteCpp/SQLiteCpp.h\"\r\n    \r\n    int main (int argc, char *argv[])\r\n    {\r\n      SQLite::Database db(\"mydb.db\", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE);\r\n      SQLite::Statement query(db, \"INSERT INTO categories (title) VALUES (?)\");\r\n      query.bind(1, \"example\");\r\n      query.exec();\r\n    \r\n      return 0;\r\n    }\r\n    \r\nmydb.db and categories table exists with id and title cols. When I run this program with valgrind I am getting this error message:\r\n\r\n    ==3857== Memcheck, a memory error detector\r\n    ==3857== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.\r\n    ==3857== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info\r\n    ==3857== Command: ./a.out\r\n    ==3857== \r\n    ==3857== Invalid read of size 4\r\n    ==3857==    at 0x4E75CB0: sqlite3SafetyCheckSickOrOk (in /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6)\r\n    ==3857==    by 0x4E80A72: sqlite3_errmsg (in /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6)\r\n    ==3857==    by 0x4021DF: SQLite::Database::~Database() (Database.cpp:77)\r\n    ==3857==    by 0x401CD0: main (in /tmp/a.out)\r\n    ==3857==  Address 0x60e91d4 is 100 bytes inside a block of size 856 free'd\r\n    ==3857==    at 0x4C29E90: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)\r\n    ==3857==    by 0x4E4DFED: sqlite3_free (in /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6)\r\n    ==3857==    by 0x4E87E14: sqlite3Close (in /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6)\r\n    ==3857==    by 0x4021C6: SQLite::Database::~Database() (Database.cpp:75)\r\n    ==3857==    by 0x401CD0: main (in /tmp/a.out)\r\n    ==3857== \r\n    ==3857== \r\n    ==3857== HEAP SUMMARY:\r\n    ==3857==     in use at exit: 0 bytes in 0 blocks\r\n    ==3857==   total heap usage: 264 allocs, 264 frees, 126,022 bytes allocated\r\n    ==3857== \r\n    ==3857== All heap blocks were freed -- no leaks are possible\r\n    ==3857== \r\n    ==3857== For counts of detected and suppressed errors, rerun with: -v\r\n    ==3857== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/SRombauts/SQLiteCpp/issues/comments/99216616","html_url":"https://github.com/SRombauts/SQLiteCpp/issues/48#issuecomment-99216616","issue_url":"https://api.github.com/repos/SRombauts/SQLiteCpp/issues/48","id":99216616,"user":{"login":"SRombauts","id":868490,"avatar_url":"https://avatars.githubusercontent.com/u/868490?v=3","gravatar_id":"","url":"https://api.github.com/users/SRombauts","html_url":"https://github.com/SRombauts","followers_url":"https://api.github.com/users/SRombauts/followers","following_url":"https://api.github.com/users/SRombauts/following{/other_user}","gists_url":"https://api.github.com/users/SRombauts/gists{/gist_id}","starred_url":"https://api.github.com/users/SRombauts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SRombauts/subscriptions","organizations_url":"https://api.github.com/users/SRombauts/orgs","repos_url":"https://api.github.com/users/SRombauts/repos","events_url":"https://api.github.com/users/SRombauts/events{/privacy}","received_events_url":"https://api.github.com/users/SRombauts/received_events","type":"User","site_admin":false},"created_at":"2015-05-05T20:48:12Z","updated_at":"2015-05-05T20:48:12Z","body":"Oh, just after one look on the Database destructor I can see that the error must be on the SQLITECPP_ASSERT() macro trying to get an error message on a database closed one line above!\r\n\r\nI shall look into recent history to see how I messed this one!\r\n\r\nI will try to reproduce and to fix this on tomorrow... "}}