Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: segfault via completion menu



Oliver Kiddle wrote on Mon, 20 May 2019 20:57 +00:00:
> Backing that out on top of master appears to fix the issue. As it was an
> optimisation, that might be an option. From reading comments in mem.c,
> it's not especially clear to me what newheaps/oldheaps do. There's only
> the one other use.

It's not too clear to me either.

The defining property of a heap, IIUC, is that freeheap() and popheap()
release all heap-allocated memory allocated since the last pushheap().
In this respect they're analogous to APR pools, which I'm familiar
with¹.

Then, what NEWHEAPS() seems to do is put away the entire stack
of heaps, create a new stack of heaps, and then OLDHEAPS() frees the
entire new stack of heaps and reverts to the old one.  How is this
better than simply doing pushheap() and popheap()?  

- Code between NEWHEAPS() and OLDHEAPS() doesn't have to be careful to
  match pushheap() and popheap() calls exactly, because OLDHEAPS() will
  clean up everything anyway.
  
- Anything allocated on heap between NEWHEAPS() and OLDHEAPS() becomes
  invalid once OLDHEAPS() is called.

- There might be some considerations about maximum depth of the stack or
  total number of bytes allocated by heaps in a single stack?

- (Anything else?)

HTH,

Daniel

¹ https://subversion.apache.org/docs/community-guide/conventions.html#apr-pools
  pushheap() ≈ { p = apr_pool_create(p); }
  popheap() ≈ { tmp = p->parent; apr_pool_destroy(p); p = tmp; }



Messages sorted by: Reverse Date, Date, Thread, Author