Add reraise_raw_backtrace primitive#378
Conversation
There was a problem hiding this comment.
@damiendoligez or @xavierleroy Could you check that my refinement of this comment is correct? If I'm wrong other part of this PR is wrong. Thank you.
|
I'm not fully functional at the moment, so instead of reviewing code I'll discuss the color of the bike shed. Concerning the name of the primitive, why not |
|
I reviewed the code and I think that it is good. The use that the primitive that is made in #374 is convincing (it brings a solution that is both definitive and non-invasive to a tricky problem), which makes me confident that the primitive is useful and that it would be interesting to have it for 4.03. The previous implementation of One small remark: |
e61dabd to
cfdda8e
Compare
|
With the name @gasche I don't understand where you want me to add the comment. There is already one about the conversion of external slot_array_of_raw_backtrace: raw_backtrace -> raw_backtrace_slot array
= "%identity"
(** Currently raw_backtrace are arrays of raw_backtrace_slot, but it
would be better that raw_backtrace match exactly the format of
caml_backtrace_buffer in order to make {!get_raw_backtrace} to
{!reraise_raw_backtrace} round-trip cost as small as possible. *)I must temper the definitive qualification. The primitive |
byterun/backtrace.c
Outdated
There was a problem hiding this comment.
@bobot : I was thinking of commenting here, to avoid people calling this function on arrays they have created themselves on the OCaml side.
cfdda8e to
ab8fc27
Compare
|
The comment is added but I think the runtime should have a way to indicate that an exported symbol should not be used, or at least that we have no backward compatibility requirement for this symbol. |
|
@xavierleroy , @damiendoligez, @alainfrisch or @def-lkb, any opinion on this change? I would like to merge it for 4.03, but I think it needs at least one extra pair of eyes. |
|
I am going to be a spoilsport, as per #358, and suggest that this wait rather than being rushed in. |
|
Could people have a new look at this PR for 4.04? |
|
I would like indeed to merge this in trunk, but probably after the remaining release work is done. |
|
I like this change and, now that #247 has been merged, I would like to move forward and eventually merge it -- along with its sister PR #374 -- in the trunk. @mshinwell (or anyone else), do you have objections? |
76aa01e to
d1c766f
Compare
|
@gasche, @damiendoligez It was accepted at the last developer meeting. I just rebased and moved the bootstrap to #374 (the developers asked to remove the bootstrap but in fact the bootstrap is needed since it is a compiler primitive and not a primitive of the runtime). |
d1c766f to
4aafc11
Compare
asmrun/backtrace_prim.c
Outdated
| } | ||
| } | ||
|
|
||
| int caml_alloc_backtrace_buffer(){ |
There was a problem hiding this comment.
Isn't int caml_alloc_backtrace_buffer(void){ still preferable (even in C-99)?
There was a problem hiding this comment.
Yes indeed. It is fixed. I tried to add the warning that detect such errors bobot/ocaml@d1f37d7, but it will wait another PR (and when I have less open PR).
|
The approach is good and the code looks fine to me once the issues above are addressed. |
e991e31 to
dd827d8
Compare
The reference given are the current results not the ideal results.
The tests show cases where the backtrace we want to use during
reraise have been lost by intermediary raise.
It reraises an exception just after copying the given backtrace to the backtrace buffer. The C primitive `caml_restore_raw_backtrace` only does the copying part, the compiler adds the reraise.
|
Call me grumpy, but I'm not completely happy with emitting code to set |
|
That would be indeed better to not increase code size. I would like to try to not reintroduce architecture specific code. I can add the generation at link time (at the same time and way (in cmmgen) than |
|
That is not so simple because the pc and sp would be of this new function and not its caller. |
|
I merged @bobot's last patch for i386nt, because I'd like to get the CI in a clean state. However, I won't have much time or connectivity in the following days, so I probably won't be able to follow the current discussion. I would be happy if someone else took care of merging or reverting changes as deemed necessary from now on. ( @alainfrisch maybe? ) |
…acktrace_primitive" This reverts commit 5adf895, reversing changes made to 38c3db4. The reason for the revert is a continuous integration failure on 32bit arm machines. I don't have the time (or capabilities) to investigate it right now, and we need functional continuous testing for other upcoming merges, so the safest choice is to revert -- and hopefully merge back after the issue is fixed.
|
Oh... @gasche I didn't understood that the changed was never merged back! I though you did it before merging my last patch. Or I'm missing something? |
|
Woops, sorry. I must admit that I forgot about it, and I don't remember what I did or didn't do. |
|
Funnily I don't understand what went wrong. You merged again my branch into trunk but only a part of the modification get back. In fact merging again |
…se_raw_backtrace_primitive"" This reverts commit f1b63d4. Conflicts: Changes
|
Reverting the revert seems to work bobot/ocaml@1248563 (branch revert-revert-reraise) , could you take it? |
|
Travis failing, I will come back with a new GPR. |
|
It was just a change of line number in hashtbl module, it doesn't mandate the trouble of a new GPR. Here the successful travis job: https://travis-ci.org/bobot/ocaml/builds/181390977 . |
…_primitive Add reraise_raw_backtrace primitive
…acktrace_primitive" This reverts commit 5adf895, reversing changes made to 38c3db4. The reason for the revert is a continuous integration failure on 32bit arm machines. I don't have the time (or capabilities) to investigate it right now, and we need functional continuous testing for other upcoming merges, so the safest choice is to revert -- and hopefully merge back after the issue is fixed.
…ace_primitive' into trunk This restores the merge of ocaml#378 which had been previously reverted to fix reraise support in some architectures: ocaml#378 (comment)
|
Just reported an issue with the reraise_raw_backtrace primitive |
| e.exp_loc)), | ||
| wrap0 (Lprim(Praise Raise_reraise, | ||
| [event_after texn1 (Lvar vexn)], | ||
| e.exp_loc)) |
There was a problem hiding this comment.
I think having both wrap and wrap0 here is a mistake, since any extra arguments in args' will be evaluated twice. Am I missing something?
Related to #1465.
There was a problem hiding this comment.
In fact this causes a segmentation fault, see https://caml.inria.fr/mantis/view.php?id=7674
Hold onto empty pools if swept while allocating
* title case and grammar/syntax in packages.eml * fixing two more title case in packages.eml * changed to Learn More Signed-off-by: Christine Rose <[email protected]>
(splitted from #374)
The function Printexc.reraise_raw_backtrace is an extension of reraise where you specify the backtrace to start with. This is what was well-received from #293 for 4.03, however this PR arrived a lot later than requested.
This PR doesn't make the heuristic try ... with e -> ...; raise e use reraise_raw_backtrace because it requires to save the backtrace and it would be going a little to far for this kind of heuristic to create allocation point where there is none.
This PR also lists different cases as new tests where wrong backtraces are used. Some can be avoided using explicitly
reraise_raw_backtrace. And one can be fixed automatically (but not done yet): when the computation of a lazy raise an exception we can store the backtrace and reraise it when the lazy is forced (cf.Camlinternallazy.force_lazy_block). But that increases the memory cost of a lazy that raises an exception, so is it worth it?