'__close' method may be called again in case of error

An error in a closing method may be caused by a lack of resources,
such as memory or stack space, and the error may free enough resources
(by unwinding the stack) to allow the method to work if called again.

If the closing method is already running after some error (including
its own), it is not called again.
This commit is contained in:
Roberto Ierusalimschy
2019-07-16 15:17:47 -03:00
parent 298f383ffc
commit c220b0a5d0
3 changed files with 32 additions and 22 deletions

View File

@@ -1548,14 +1548,15 @@ they are closed in the reverse order that they were declared.
If there is any error while running a closing method,
that error is handled like an error in the regular code
where the variable was defined;
in particular,
the other pending closing methods will still be called.
where the variable was defined.
However, Lua may call the method one more time.
After an error,
other errors in closing methods
the other pending closing methods will still be called.
Errors in these methods
interrupt the respective method,
but are otherwise ignored;
the error reported is the original one.
the error reported is only the original one.
If a coroutine yields and is never resumed again,
some variables may never go out of scope,