[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: *toclose and custom stack traces
- From: nobody <nobody+lua-list@...>
- Date: Thu, 25 Apr 2019 21:55:21 +0200
(Sometimes I like my stack traces to include _all_ local variables and
upvalues – many typos become obvious once you see the values as they are
when the error happened, this can be a _huge_ time saver!)
Previously, the way to guarantee that you can generate a custom stack
trace was to wrap your function as a coroutine, run that, and on error,
inspect the dead coroutine's preserved stack. (xpcall doesn't work,
it's not always called – e.g. on memory allocation failure.)
On the current git HEAD, the *toclose support unwinds the stack of the
coroutine before it can be inspected. (And the error behavior of
coroutines to return false, errormsg _without_ a stack trace is still
unchanged, so you have approximately zero information to work off when
debugging stuff that uses coroutines.)
How will debugging in 5.4 (roughly) work (once it's finished)?
-- nobody
(Based off my knowledge, the simplest thing would probably be to let
xpcall call its error handler for _all_ errors (also gets rid of an
occasional source of confusion), and maybe have an optional argument for
`coroutine.create( function[, errorhandler] )` because otherwise the
lowest stack level of most coroutines would be manually setting up an
xpcall around its actual inner function…)