ruben2020 / codequery

A code-understanding, code-browsing or code-search tool. This is a tool to index, then query or search C, C++, Java, Python, Ruby, Go and Javascript source code. It builds upon the databases of cscope and ctags, and provides a nice GUI tool.
https://ruben2020.github.io/codequery/
Mozilla Public License 2.0
680 stars 86 forks source link

fixes segv crash caused by double close of sqlite3 db. Fixes #39? #60

Closed brianonn closed 7 years ago

brianonn commented 7 years ago

cqmakedb crashed with a segmentation violation at the very end of it's run.

Class ctagread has sqlbase for its base class, and the db is closed inside of the ctagread class. The inherited member m_db is used here as the argument to the library function sqlite3_close(). When the ctagread instance goes out of scope, the base class destructor is eventually called and the base class calls sqlite3_close() one more time. In my case, it was called with an invalid pointer, causing the segmentation violation. I suspect this is the same bug described in #39

ruben2020 commented 7 years ago

Wow! Great. Thanks! @brianonn

Actually, sqlite3_close could be called harmlessly on a NULL pointer. https://sqlite.org/c3ref/close.html

brianonn commented 7 years ago

@ruben2020 Good to know. NULL pointers are ok then, so you can save an if().

Thanks for making your tool available. I decided to give it a try when I needed case-insensitive lookups for just a few symbols. cscope wasn't giving me that. With cscope, your only choice is to make the the entire database case insensitive (or not). Your tool handles this use case better, and it's fast with the sqlite3 db. I like the function call graphs and class inheritance graphs for looking at new code too.