Re: RFC: introduce scoped cleanups

Tom Tromey
2013-05-31T20:24:03Z

Pedro> Seeing Tom's scope cleanups were already stack based and most of
Pedro> the way there, made me feel that it'd be a pity to be able to
Pedro> have stack-based cleanups, but then as soon as you need a real
Pedro> cleanup that does actual cleanup (as opposed to null_cleanup),
Pedro> you still need to get back to install a heap cleanup anyway.

My one concern about this code is that, if a stack cleanup should be
leaked, then any future cleanup operation will refer to invalid memory.

Right now, cleanup failures like this are a memory leak with the
possibility of wrong behavior -- but the new way seems more directly
fatal.

Another option would be to allocate cleanups on an obstack.
This would often be efficient and would avoid the above problem.

This approach would either have to still leave the special scoped
cleanup on the stack, at least when compiling with GCC (and perhaps only
if in "development=true" mode); or we would need to come up with some
extra hack to make this work properly with obstack allocation.

Tom