Use raise_with_backtrace instead of raise#1
Open
Willenbrink wants to merge 2 commits intocraigfe:mainfrom
Open
Use raise_with_backtrace instead of raise#1Willenbrink wants to merge 2 commits intocraigfe:mainfrom
Willenbrink wants to merge 2 commits intocraigfe:mainfrom
Conversation
|
It seems the backtrace is not lost during the re-raising, at least in newer OCaml. I wonder if you have a concrete example showing the loss? (I made this mistake before...) |
Author
|
I think this is unrelated as I can reproduce the problem on your branch. The problem I fixed is shown by this program (found in test/passing/main.ml on this branch): open Stdlib.EffectHandlers.Deep
exception%effect E: unit
let () =
Printexc.record_backtrace true;
let raiser () = raise Not_found in
match raiser () with
| e -> e
| [%effect? E, k] ->
continue k ()Without my patch this prints: With the patch it results in: As you can see the original raise is not present in the first backtrace but is in the second one. I did notice that my patch only fixes this for |
Where did it come from? Is that a change in 5.0.0 beta1 -> 5.0.0?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey,
when an exception is raised within a continuation the backtrace is lost as we catch the exception and simply re-raise it. This PR exchanges
Stdlib.raisebyPrintexc.raise_with_backtraceso this information is not lost.I'm not sure exactly how large the performance impact is but it should be insignificant. In addition, I assume it is even cheaper if backtraces are currently not recorded or the exception was raised with
Stdlib.raise_notrace.