[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: More on errors in finalizers (was: [ANN] Lua 5.4.0 (alpha) now available)
- From: David Heiko Kolf <david@...>
- Date: Sun, 16 Jun 2019 10:46:08 +0200
Andrew Gierth wrote:
> So, is there any likelihood of changes with regard to the error
> handling issues, or do I put up my "this project will never support
> Lua 5.4" notice now?
I have now checked how .NET handles errors during garbage collection and
noticed this discussion on Stack Overflow:
<https://stackoverflow.com/questions/2692004/c-sharp-finalizer-throwing-exception>
In summary, .NET 1.1 just ignored exceptions during GC, later .NET
versions kill the entire application regardless of any try-catch blocks.
<https://docs.microsoft.com/en-us/dotnet/api/system.object.finalize?view=netframework-4.8>:
> If Finalize or an override of Finalize throws an exception, and the
> runtime is not hosted by an application that overrides the default
> policy, the runtime terminates the process and no active try/finally
> blocks or finalizers are executed. This behavior ensures process
> integrity if the finalizer cannot free or destroy resources.
I am not sure how that could be translated to Lua, I don't want Lua to
terminate the host application. But whatever the solution, it should
work well with plain Lua and not just a specialized implementation of pcall.
As a further remark, I have been taught that exceptions in finalizers
(in any programming language) should be avoided at all costs, so I hope
my applications never trigger it.
Regarding the associated lua_WarnFunction I am feeling more and more
uneasy, but that is probably a topic for its own thread.
Best regards,
David