Book Closing in HEAD kills objects in a "bad" order, corrupts memory.

Josh Sled jsled at
Tue May 25 11:43:10 EDT 2004

On Tue, 2004-05-25 at 10:33, Derek Atkins wrote:

> I instrumented qof_object_book_end to print out the object it was
> closing out (not included in the patch below).  As you can see, it's
> closing out the CommodityTable before the AccountGroup, which is bad.

Seems like that list of things-to-destroy needs to be in the right
order... or we need to introduce reference-counting...

> As you can see from the following trace this causes a memory access
> failure because transactions are kept in balance even when we're
> destroying the book, so it's trying to scrub against an
> already-destroyed commodity.

Why do we need to scrub things we're just trying to get rid of?  It
seems like the scrubbing is best conditional on how the destruction in
coming about.

> DEBUG: Enter: qof_object_book_end
> DEBUG: Debug: qof_object_book_end(): Closing CommodityTable
> DEBUG: Debug: qof_object_book_end(): Closing Price
> DEBUG: Debug: qof_object_book_end(): Closing Scheduled Transaction Templates
> DEBUG: Debug: qof_object_book_end(): Closing AccountGroup

What should the order be...?  I'm thinking...

* Business objects / SX templates
* Splits / Transactions
* Accounts / Price-DB
* Commodities / Lots [?]
* Session state [?]
* Book



-- - `a=jsled;; echo ${a}@${b}`

More information about the gnucash-devel mailing list