Re: [patch 2/2] Assert leftover cleanups in TRY_CATCH

Joel Brobecker
2013-05-07T06:23:15Z

> Thanks for doing this. I think it is a nice addition.

I agree. My only additional comment, after having hit this assertion,
is that it seems a bit harsh to be doing an abort in this case.
The problem showed up during a testsuite run, and so I would
investigate it regardless. But I can imagine the same issue
occurring during a real debugging session trying to chase a bug -
I'd be pretty upset to see my session ended like that.

Should we consider changing it into an internal_warning?

> We could do this for all cleanup-creating functions, at least when using
> GCC, if we didn't mind putting a declaration at the start of each such
> function:
>
> #if ... gcc ..
> #define CHECK_CLEANUP \
> struct cleanup *__dummy ## __LINE__ \
> __attribute__ ((cleanup (check_cleanup))) \
> = get_checking_cleanup_pointer ();
> #endif
>
>
> This would call check_cleanup when the function exited normally, so we
> could verify that the cleanup chain was properly reset.

That would have helped my investigation, because the error
was raised in a frame long after the function causing the problem
had returned. Looking at the contents of the cleanup_chain,
you get a hint of what it might be, but in my case, it was
a null_cleanup, so not so helpful...

> I think it would be possible to automate adding this declaration in
> all needed spots. I'm curious what you think about it.

I'm certainly curious about the suggestion. How would the current
code be adapted to make this work?

--
Joel