Frames not freed timely in exception unwinding with named lambdas
Imported from http://bugzilla.roxen.com/bugzilla/show_bug.cgi?id=1937
Reported by Martin Stjernholm mast@roxen.com
When the error is thrown in the following program, the ref to the MutexKey k is not freed during the exception unwinding. It thus causes the x->lock() after the catch to fail with a recursive mutex locks error. A gc() call frees the key.
Thread.Mutex x = Thread.Mutex();
void f()
{
Thread.MutexKey k = x->lock();
int i = 17;
void sub (int k)
{
if (k < i) sub (k + 1);
error ("x\n");
};
sub (0);
}
int main()
{
catch (f());
werror ("%O\n", x->lock());
}
I consider this a bug, since much code counts on that mutex keys in local variables are freed on exception unwinding. Also, there are no dynamic frames involved that have reason to exist outside the call to f. The problem exists in all 7.x versions.