tree-sitter-markdown icon indicating copy to clipboard operation
tree-sitter-markdown copied to clipboard

fix oom

Open dimbleby opened this issue 3 years ago • 7 comments

This addresses - but does not exactly fix - the out-of-memory reported in #32.

I have removed a block of code which, I suppose, is somehow mis-handling this case. This isn't a clean fix, we now go on to hit the assertion that follows: but with TREE_SITTER_MARKDOWN_AVOID_CRASH we catch this error and seem to recover.

The input:

[foo](*https://example.com
[foo](*https://example.com

now parses as:

(document [0, 0] - [1, 26]
  (paragraph [0, 0] - [1, 26]
    (link [0, 0] - [0, 5]
      (link_text [0, 1] - [0, 4]
        (text [0, 1] - [0, 4])))
    (text [0, 5] - [0, 7])
    (uri_autolink [0, 7] - [0, 26]
      (text [0, 7] - [0, 26]))
    (soft_line_break [0, 26] - [1, 0])
    (link [1, 0] - [1, 5]
      (link_text [1, 1] - [1, 4]
        (text [1, 1] - [1, 4])))
    (text [1, 5] - [1, 7])
    (uri_autolink [1, 7] - [1, 26]
      (text [1, 7] - [1, 26]))))

I was expecting an error! But this doesn't look stupid, and certainly is a lot better than looping and consuming all available RAM.

dimbleby avatar Oct 15 '21 13:10 dimbleby

@ikatyang I see that this project has been quiet for a few months. Is it still alive?

With my fixes / workarounds here and at #36, the parser is currently holding strong against the fuzzer. (It has only been an hour, so too soon to declare victory - but that's definite progress!)

If that continues to be the case, I imagine that eg neovim might want to revive their interest in using this. So it would be good to get a sign as to whether this is a going concern or not.

dimbleby avatar Oct 15 '21 14:10 dimbleby

I do a lot of markdown editing and would love to be able to have syntax highlighting!!

NullVoxPopuli avatar Oct 15 '21 19:10 NullVoxPopuli

@dimbleby after 17 days, does it still appear to be holding strong? If yes, @ikatyang , it would be nice if you could consider these PR's. We're all pretty excited about the efforts being pushed forward by @dimbleby

pappasam avatar Nov 01 '21 18:11 pappasam

I stopped after a few hours. Certainly that's too soon to promise that there's nothing left to find: but it's considerably longer than the fuzzer has previously taken to find issues.

dimbleby avatar Nov 01 '21 18:11 dimbleby

it looks like the project maintainer @ikatyang isn't active anymore. Maybe we can fork and include prs?

Lunarequest avatar Nov 10 '21 11:11 Lunarequest

IMG_20220502_112211 atom:titleDefault</atom:title> atom:titlePackages</atom:title> 2017_OFCCP_Pre-Award_Ref_Guide_Inter_5-17-17-Final_508COMP.pdf

Hmgov avatar May 11 '22 00:05 Hmgov

the finel todays github imjiniaring world war ll

Hmgov avatar May 14 '22 16:05 Hmgov