Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upOptionally call winch::winch_add_trace_back() when collecting stack trace #1039
Conversation
|
I would think the proper hook is |
|
I would have to rebuild a ton of rlang infrastructure to achieve compatibility with Also I'm having a very hard time updating stack traces generated by |
It shouldn't be too late to use |
|
Line 136 in a144ac0 |
|
Results with libunwind are much better, see
Test run: https://github.com/r-prof/winch/runs/965694700?check_suite_focus=true#step:11:171. |
Right but as a calling handler you can create another trace if you'd like. We may also move the trace capture at a later stage (after the signalCondition) in the future, I don't remember why we didn't end up doing that (it was the original plan). |
|
It would be good to add C stack support to the entracing in rlang, probably not with a hook though. |
|
It would be good to come to some sort of conclusion here. I don't think we need a long-term solution immediately, but we do need something so that we all can start to try out the R/C tracebacks in our own work and see how they feel. |
|
Instead of a hook I think rlang should call winch if installed. |
|
That's fine with me too |
|
Done now. |
| @@ -92,6 +92,13 @@ trace_back <- function(top = NULL, bottom = NULL) { | |||
| trace <- new_trace(calls, parents) | |||
| trace <- trace_trim_env(trace, frames, top) | |||
|
|
|||
| if (is_installed("winch")) { | |||
lionel-
Sep 14, 2020
Member
This should probably be opt-in during development? I.e. is_true(peek_option("rlang_trace_use_winch")).
Can you document what winch is doing? Is it making any assumptions about the trace internals? Note that these internals are not stable yet, we still have some work to do to match Gabor's traces.
This should probably be opt-in during development? I.e. is_true(peek_option("rlang_trace_use_winch")).
Can you document what winch is doing? Is it making any assumptions about the trace internals? Note that these internals are not stable yet, we still have some work to do to match Gabor's traces.
krlmlr
Sep 14, 2020
Author
Member
I'm adding and modifying rows in the data frame, relying on the internal structure. Would it be better to provide a drop-in replacement for sys.calls() and sys.frames() instead?
I'm adding and modifying rows in the data frame, relying on the internal structure. Would it be better to provide a drop-in replacement for sys.calls() and sys.frames() instead?
| @@ -92,6 +92,13 @@ trace_back <- function(top = NULL, bottom = NULL) { | |||
| trace <- new_trace(calls, parents) | |||
| trace <- trace_trim_env(trace, frames, top) | |||
|
|
|||
| if (is_installed("winch")) { | |||
| new_trace <- winch::winch_add_trace_back(trace) | |||
| if (inherits(new_trace, "rlang_trace")) { | |||
lionel-
Sep 14, 2020
Member
Why would this not inherit from rlang_trace?
Why would this not inherit from rlang_trace?
|
Fixed now. Added versioned option to allow for incompatible changes. |
|
winch 0.0.1 is on CRAN now. |
|
Can you take a quick look at these changes @krlmlr? I'm sending rlang to CRAN today |
|
Thanks a lot Kirill! |
|
rlang 0.4.8 is on CRAN |
This is for capturing a native stack trace when the error occurs. See the examples at https://github.com/r-prof/winch/pull/4/checks?check_run_id=961027969#step:10:28 and below. I hope to get better native stack traces with libunwind (r-prof/winch#2), I rather like how this seems to work already in all cases (
stop(),Rf_error()andabort()).Would you support this in rlang? I understand that we want to document and stabilize the structure of the
"rlang_trace"before exposing it, and that we need tests. I don't mind marking this as "experimental".