-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Experiments to fix the goals not showing on errors. #429
base: master
Are you sure you want to change the base?
Conversation
(setq proof-shell-delayed-output-start (point-max)) | ||
(setq proof-shell-delayed-output-flags flags) | ||
(when t; (proof-shell-exec-loop) | ||
(sleep-for 0 100) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without this it won't work. This suggests it should be put in some callback instead...
I am still trying to understand the problem. When I process the two intro lines together without the patch of this PR, then the goals buffer shows some old goal. Instead, the goals buffer should show the goal before the wrong intro command, that is, the goal after having processed the first |
Yes it is exactly the problem. there is one way to fix this: to make coqtop -emacs always do "Show" just before printing an error. This was the previous behaviour of coqtop since #188. But it won't work for a few version of emacs. I experimented an adhoc solution on pg side here. |
Just for the record, there is a possibly related issue of the goals buffer not being updated even after successfully reaching the point, if the point is located right after a comment #204. |
Pierre, you are extending the action list in the middle of the process filter. Because of the error, the action list has been cleaned already, therefore the show command is sent immediately to Coq, however, Coq needs some time to respond. This is the reason why it won't work without sleeping. Also, as long as you are sitting in the process filter, calling the process filter for the output of the show command is blocked (see proof-shell-filter-wrapper). To deal with this, you parse the output yourself and call a piece of the process filter after waiting (proof-shell-handle-delayed-output). All this looks really fragile IMO. I would suggest to only insert the show command in the action list and then leave the process filter straight away. When the output arrives, the process filter will be called again and will then take care of it in the usual way. With this approach you'll probably have the problem that the error is not properly signaled any more (the last show was successful after all). To deal with this I would suggest to add appropriate flags and callbacks to the action item and designing new flags and action items if the currently present ones are not sufficient. If you give me some more time, I'll make a proposal. |
Le mer. 11 sept. 2019 à 11:13, hendriktews <[email protected]> a
écrit :
Pierre, you are extending the action list in the middle of the process
filter. Because of the error, the action list has been cleaned already,
therefore the show command is sent immediately to Coq, however, Coq needs
some time to respond. This is the reason why it won't work without
sleeping. Also, as long as you are sitting in the process filter, calling
the process filter for the output of the show command is blocked (see
proof-shell-filter-wrapper). To deal with this, you parse the output
yourself and call a piece of the process filter after waiting
(proof-shell-handle-delayed-output). All this looks really fragile IMO.
Indeed this is.
I would suggest to only insert the show command in the action list and
then leave the process filter straight away.When the output arrives, the
process filter will be called again and will then take care of it in the
usual way.With this approach you'll probably have the problem that the
error is not properly signaled any more (the last show was successful after
all).
Yes. This would hide the error message.
To deal with this I would suggest to add appropriate flags and callbacks
to the action item and designing new flags and action items if the
currently present ones are not sufficient. If you give me some more time,
I'll make a proposal.
Good idea. Thank you Hendrik.
P.
|
Designing flags and callbacks, of course. |
Most of these tests currently fail because of different instances of ProofGeneral#568, see also ProofGeneral#429, ProofGeneral#467.
In rare cases (e.g. once in 40 hours of working in company-coq), I used to see this problem EVEN when proof-goto-point did not end in an error or a comment (the 2 known problematic cases). It was very hard to reproduce. But now that I run coqtop in a docker container (to use dune cache from a CI job running in an identical docker container), I see this error more than half the times. Here is my "coqtop" which wraps the coqtop in the docker container
I can demonstrate the problem in a zoom call and/or produce instructions to reproduce the issue; the latter would require some administrative approval at my employer but should be doable. |
Great thanks for this work @aa755. I would be happy to take some time to understand the problem. It would be nice if @hendriktews could join because he has some good understanding of the internal loop of PG. |
Some update:
It is possible studying what happens without |
In itself this gives some clue already. Thanks again for the work. |
Sorry, it took longer to produce the reproduction instructions. The following zip file has scripts and .v files to demonstrate the problem: |
I finally took some time to have a look. Great job at isolating the bug! Extremely helpful: when looking at the ...
<prompt>Coq < 42 || 0 < </prompt>Lemma log2_spec n : 0 < n -> 2^(log2 n) <= n < 2^(succ (log2 n)).
<prompt>log2_spec < 43 |log2_spec| 0 < </prompt>1 goal (ID 3)
n : N
============================
0 < n -> 2 ^ log2 n <= n < 2 ^ succ (log2 n) As you can see the prompt comes before the goal! This is very strange and should never happen. It certainly causes the goal not being printed. |
@ejgallego @gares @maximedenes can you have a look please? Why would coq display the goal after the prompt? |
A bit of context: @aa755 is running coqtop inside a docker image and is getting a strange behaviour where prompt and goals are printed in an unexpected order very frequently. Things come back to normal if running So the docker case should help us spot this otherwise rare bug. Hence the question: why would coq swap goal and prompt printing in any case? |
More info: I can trigger this print swap without the
|
@Matafou certianly there could be a problem with the flushing, this part has been tricky since 8.5 introduced the feedback mechanism. First places to look are:
I'd try changing the flush order in the first line for example. |
Thanks @ejgallego that makes sense to look there. But my intuition is that printing errors first is correct (error messages are more urgent?). Maybe the problem is that the prompt is printed on error channel... Or is it standard?? It has been like that for decades I suppose... |
I think printing order is correct, flush order may not be. |
We need this ordering of appearance: WARNINGS/ERRORS Which suggest IIUC that ERRORS should be flushed first, BUT ALSO that the prompt should not be printed on the error channel, as it is currently. |
Flushing is per-formatter, also per out channel. Both flushings can race as in it is possible to write to a formatter on out channel This is a Coq bug so I'd suggest reporting there to see if some Coq developer would like to have a look. |
OK I will submit a bug report. |
Note that this races with the per channel flushing. But it seems the problem here is more about the order of flushing. That's pretty strange tho, as each of the operations here seem to flush so the order should be preserved.
I don't know. |
Which seems to cause [this PG bug](ProofGeneral/PG#429 (comment)).
Which seems to cause [this PG bug](ProofGeneral/PG#429 (comment)).
@aa755 can you try https://github.com/Matafou/coq/tree/fix-prompt-err-17753 and see if the bug is fixed? |
sure. I will try soon. |
In your version (https://github.com/Matafou/coq/tree/fix-prompt-err-17753), after doing
You can reproduce it the same way as before, except that I have updated the script to set up the docker image, so that now it installs the custom coq version https://github.com/aa755/pgissuedocker/blob/master/setup.sh |
Most of these tests currently fail because of different instances of ProofGeneral#568, see also ProofGeneral#429, ProofGeneral#467, ProofGeneral#103.
Most of these tests currently fail because of different instances of ProofGeneral#568, see also ProofGeneral#429, ProofGeneral#467, ProofGeneral#103.
Most of these tests currently fail because of different instances of ProofGeneral#568, see also ProofGeneral#429, ProofGeneral#467, ProofGeneral#103.
This is in no way a real pull request, just experiments to understand how we could insert a "Show" command after an error occured. It comes from a discussion with @hendriktews.
In its current state the patch "works". But it is certainly not in the right place and needs to be made less adhoc. See comments in the patch.
To reproduce the bug without this patch and see how it is fixed with it, follow these instructions.