Originally Posted by kovidgoyal
I'm not yet convinced its the new SQL that's causing the problem. I suspect instead a GUI issue.
I was the one who was having problems.
Seems that Kovid was correct (what a surprise), although the 'why' of it isn't obvious to me. The problem occurred when a new saved search was added, causing the main window GUI to ask the tags pane to update the list of saved searches. I used an existing method to do that, because the method went to some pains to preserve the screen position of tags. Apparently this caused the problem (calibre crashed). When I changed it to instead refresh the tags pane and lose the position, the crash went away.
My theory, based on ignorance and superstition, is that the position preservation somewhere preserves a pointer to a node. Unfortunately, refreshing the tags will rebuild the node list, leaving the pointer referring to an area of memory now used by something else. Nothing good can come of this.
If I am right, then tags_view.recount() probably should not be used (it is used currently only when the database changes underneath the GUI, a rare event?). However, my theory is not far from waving wands and muttering incantations, and should be interpreted accordingly.