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

Randomly infinite loop #354

Closed
dalance opened this issue Jun 18, 2024 · 5 comments
Closed

Randomly infinite loop #354

dalance opened this issue Jun 18, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@dalance
Copy link

dalance commented Jun 18, 2024

I found a strange issue which a broken source code causes infinite loop randomly.
The reproduce way is below:

The expected behaviour is parse failure like below.
Actually, infinite loop frequently occuers instead of it.

Error: ParserError::SyntaxError

  × Unexpected token: '}'
   ╭─[/home/hatta/temp/veryl/test.veryl:2:1]
 2 │     always_ff (i_clk)
 3 │ }
   · ┬
   · ╰── Error location
 4 │
   ╰────
  help:

I thought the parsing by parol is deterministic.
Is there any issue which causes the randomness?

@jsinger67
Copy link
Owner

@dalance,
I will have a look at it later today.
Parol should in deed be deterministic.
Maybe you found a bug.
Infinite loops actually can only occur when the tokenizer can't make any progress in the input. Another scenario could be related to the recovery process that starts with the first error seen.
If you have time you could have a look at the Q&A page of the parol book. There's a question
https://jsinger67.github.io/QnA.html#q-i-get-strange-errors-while-commissioning-my-new-grammar-and-cant-figure-out-what-the-problem-is
You can activate some traces to help pin down the problem.

@jsinger67
Copy link
Owner

I can reproduce this scenario.

If I enable trace logs I get a panic in main.rs:
image
I'll try to circumvent this here locally.

@jsinger67 jsinger67 added the bug Something isn't working label Jun 18, 2024
@jsinger67
Copy link
Owner

The problem is related to the termination behavior of the recovery process.
The reason for the non-deterministic behavior is not clear yet and I'll have to take a deeper investigation for this scenario.
Thank you for reporting this issue, @dalance!
I'll change the label to bug and try to provide a fix soon.

@jsinger67 jsinger67 self-assigned this Jun 18, 2024
@jsinger67
Copy link
Owner

@dalance, in the meamwhile I have a fix.
The reason for the unsettling non-deterministic behavior was due to my use of petgraph in recovery calculations.
The graph data was obviously internally randomly sorted.
Moreover there was a problem with the termination of recovery process which only occurred in certain scenarios.
I will test this thoroughly and provide a new release for the parol_runtime crate at the weekend.

@jsinger67
Copy link
Owner

Fixed with commit 9e9a534
@dalance, please update to [email protected] and [email protected]
Again, thanks for reporting and keep up your good work 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants