# Tring to fix a bug in elm-markup: infinite loop by '{'

**URL:** https://discourse.elm-lang.org/t/tring-to-fix-a-bug-in-elm-markup-infinite-loop-by/8006
**Category:** Learn
**Created:** [December 18, 2021, 2:24pm UTC](https://discourse.elm-lang.org/t/tring-to-fix-a-bug-in-elm-markup-infinite-loop-by/8006 "2021-12-18T14:24:02Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Cisper](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/cisper/32/4286_2.png) [@Cisper](https://discourse.elm-lang.org/u/Cisper)
#### Post date: [December 18, 2021, 2:24pm UTC](https://discourse.elm-lang.org/t/tring-to-fix-a-bug-in-elm-markup-infinite-loop-by/8006/1 "2021-12-18T14:24:02Z")

</div>

I have been playing around with Elm-Markup and found it is for my purposes a big step forward from Markdown. However, there is one issue, there is a known [bug](https://github.com/mdgriffith/elm-markup/issues/29) that when the markup parser is fed a single ‘{’ character, the app gets stuck in an infinite loop 👻 ( [Ellie demo](https://ellie-app.com/6hPMtnKj2j3a1)). I thought it could be a nice exercise to improve my understanding of parsers by trying to fix the bug, however I got stuck on two issues:

1. It seems that the source code of “elm-markup” on [packages.elm.org](http://packages.elm.org) and the github repo are not the same. I can compile the examples only, if I replace the examples elm.json and supply them with the “official” package instead of that of the Github repo, so something got out of sync?

2. Is there a clever strategy to debug these type of infinite loops? My intuition is to search for whatever parser deals with ‘{’ chars and test them one by one. Does anybody have a hint on what functions within elm/Parser are likely to trigger infinite loops?

---

<div class="post-metadata">

### Author: ![Cisper](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/cisper/32/4286_2.png) [@Cisper](https://discourse.elm-lang.org/u/Cisper)
#### Post date: [December 18, 2021, 8:33pm UTC](https://discourse.elm-lang.org/t/tring-to-fix-a-bug-in-elm-markup-infinite-loop-by/8006/2 "2021-12-18T20:33:16Z")

</div>

Have found that removing [this line](https://github.com/mdgriffith/elm-markup/blob/b073d85490f71c6491648bcd0b11bf9aca6e53a5/src/Mark/Internal/Parser.elm#L1245) at least solves the infinite loop, and doesn’t seem to break anything too essential, so good… for now.

---

<div class="post-metadata">

### Author: ![cwhy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/cwhy/32/558_2.png) [@cwhy](https://discourse.elm-lang.org/u/cwhy)
#### Post date: [December 20, 2021, 4:00am UTC](https://discourse.elm-lang.org/t/tring-to-fix-a-bug-in-elm-markup-infinite-loop-by/8006/3 "2021-12-20T04:00:36Z")

</div>

What a coincidence 😆. I met the same bug yesterday

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)
#### Post date: [December 30, 2021, 4:01am UTC](https://discourse.elm-lang.org/t/tring-to-fix-a-bug-in-elm-markup-infinite-loop-by/8006/4 "2021-12-30T04:01:28Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
