mattmower

mattmower

I’ve twice now created a parser that hangs, that is given a finite input string a call to parse_xxx it never returns and the beam.smp process is consuming ~100% of a core.

I’m usually making a small, seemingly innocuous, change to the string being parsed that causes the hang.

Should this actually be possible?

Thanks.

Matt

Showing Posts 4 to 1

mattmower

mattmower OP

As a further note here, in the (much simpler) parser combinator library I built called Ergo I have implemented cycle detection and the parser will automatically halt with a trace of the history of rules. A bit primitive right now but I’ve found it useful when playing with a new grammar.

mattmower

mattmower OP

Thank you Jose.

I had read that but hadn’t appreciated what it was saying. I do have a few cases where repeat and optional get combined and I suspect this is what is happening.

Part of the problem is that I find my error handling strategy is “fiddle with it a bit” because I find the error information difficult to work with. Any guidance about (or good examples of) that would be much appreciated.

Thanks.

Matt

josevalim

josevalim

Creator of Elixir

Yes, it can loop forever. Usually the culprit is repeat. Its docs has warnings on when such cases may happen:

If you are still running into loops, then a minimal parser that reproduces the failure would be welcome.

trarbr

trarbr

I have seen it hang if I wrote a parser that would infinitely recurse. Unfortunately I can’t recall the details, but I fixed it by changing my parser. If you can’t find any infinite recursion happening, it might be a bug in NimbleParsec?

Anyway, if you want to guard against the parser hanging, you might want to wrap the parsing in a Task

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
water
I’m aware of 2 such projects, are there others? git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
itzmidinesh
Hi all, I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
pragdave
How do I tell Hologram not to escape HTML when substituting into templates? {Textile.render(@product.long_description)} escapes the HTM...
New
rlipscombe
I’d like to create a file with 600 permissions (rw-------), but there’s a race condition if I create it and then change the permissions. ...
New
leoschweizer
Hi, we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
rlipscombe
When I use Mix.install with a git dependency, using git@github.com:... how do I change the SSH identity used? I’ve got two Github accoun...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
raa-ziq
Hi everyone :waving_hand: I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews