Skip to content
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

new parser hangs on some syntax errors #7847

Closed
vicuna opened this issue Sep 3, 2018 · 5 comments
Closed

new parser hangs on some syntax errors #7847

vicuna opened this issue Sep 3, 2018 · 5 comments

Comments

@vicuna
Copy link

vicuna commented Sep 3, 2018

Original bug ID: 7847
Reporter: smuenzel-js
Assigned to: @gasche
Status: resolved (set by @gasche on 2018-09-06T08:18:14Z)
Resolution: fixed
Priority: normal
Severity: major
Version: 4.07.0
Fixed in version: 4.08.0+dev/beta1/beta2
Category: lexing and parsing
Monitored by: smuenzel-js @nojb @hhugo @gasche

Bug description

The following code results in a hang (in Parse.ml, around line 109):

external x : unit -> (int,int)`A.t = "x"

@vicuna
Copy link
Author

vicuna commented Sep 3, 2018

Comment author: @gasche

Thanks for the report!

The nontermination comes from the Parse.loop function, which seems to hit the HandlingError case infinitely often instead of progressing towards Rejected.

@vicuna
Copy link
Author

vicuna commented Sep 3, 2018

Comment author: @gasche

smuenzel-js: out of curiosity, how did you hit this issue? I'm curious at whether this comes from tests that you are running on your own, or casual usage of trunk. In any case, this is very useful.

@vicuna
Copy link
Author

vicuna commented Sep 3, 2018

Comment author: @hhugo

The is the result of some experiment with afl fuzz

@vicuna
Copy link
Author

vicuna commented Sep 3, 2018

Comment author: @gasche

Interesting! I hope that the harness setup will be made available for others to play with.

(I have a perpetually-delayed side-project idea to do differential testing of OCaml implementations by combining https://github.com/jmid/efftester (the evaluation-order-aware code generator) and https://github.com/johnwhitington/ocamli (or another reference implementation.)

@vicuna
Copy link
Author

vicuna commented Sep 6, 2018

Comment author: @gasche

After some debugging by Frédéric Bour and myself, the issue was fixed by François Pottier in trunk:

#2019

We believe that no other similar issue should pop up in the future with the current grammar, as it is due to a corner case (raising a parser-internal exception from a semantic action) which has now disappeared from the grammar.

Thanks again for the prompt testing and reporting!

@vicuna vicuna closed this as completed Sep 6, 2018
hhugo pushed a commit to hhugo/ocaml that referenced this issue Mar 17, 2019
[core_type_comma_list] with [core_type], as this is what is really intended:
allow a single type. This removes the need for raising [Parsing.Parse_error]
in the semantic action, and should fix bug ocaml#7847. This change alone would
create a conflict in the grammar, which is avoided by replacing
[core_type_comma_list] with [inline_core_type_comma_list] in two places.
hhugo pushed a commit to hhugo/ocaml that referenced this issue Mar 17, 2019
@vicuna vicuna added the bug label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants