j-mie6 / parsley

A fast and modern parser combinator library for Scala
https://j-mie6.github.io/parsley/
BSD 3-Clause "New" or "Revised" License
173 stars 15 forks source link

Remove `StackOverflowError` catching, use explicit `overflows` instead #144

Closed j-mie6 closed 1 year ago

j-mie6 commented 1 year ago

Parsley previously used a safeCall mechanism to run the internal compiler in a stack-unsafe way and revert to a stack-safe version if it threw a StackOverflowError. This is not safe: this is a fatal error, and the JVM may be left in an inconsistent state after "recovery" and on Native a stack-overflow is undefined behaviour. Both not good things to be relying on. As such the automatic recovery has been removed: if a stack-overflow occurs before parsing begins then use .overflows() on the parser that is having .parse called on it to compile it in a stack-safe way. The same goes for users who wish to be immune from any potential stack-overflows full-stop.

Thanks to @armanbilge for letting me know!

codeclimate[bot] commented 1 year ago

Code Climate has analyzed commit 2978ba5f and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 91.7% (0.1% change).

View more on Code Climate.

armanbilge commented 1 year ago

Further reading: