redcarpet icon indicating copy to clipboard operation
redcarpet copied to clipboard

Raising errors in callbacks crashes a Markdown instance

Open adamflorin opened this issue 11 years ago • 2 comments

Please see reproducible case:

https://gist.github.com/adamflorin/7045640

If I use a Markdown instance repeatedly to render text, and raise an error within a custom formatting callback, eventually Redcarpet (or Sundown?) will crash, bringing down Ruby with it, with the error:

Assertion failed: (md->work_bufs[BUFFER_BLOCK].size == 0), function sd_markdown_render, file markdown.c, line 2544.
Abort trap: 6

In my case, I can just instantiate a new Redcarpet instance each time I render, so this is not pressing for me. But perhaps of interest to you?

adamflorin avatar Oct 18 '13 18:10 adamflorin

FWIW

I get the same error by essentially this:

Attach my renderer somewhere accessible:

NameSpace.text_renderer = Redcarpet::Markdown.new(TextRenderer, opts)

Spin up an instance, and inside that instance call it again:

text_renderer.render text
  ### Inside TextRenderer
  def block_code(file_path, content)
    # . . .
    NameSpace.text_renderer.render content
    # . . .
  end

I'll use @lynxnathan's suggestion of just making a new instance but thought I'd pass on another use case.

(In my case, I'm not using the fenced code block for code, I'm using it for a figure caption, and I want to be able to put bold text etc in the figure caption, thus I need to render inside as well).

KCErb avatar Apr 28 '15 17:04 KCErb

We're seeing this also: RedCarpet 3.3.4, Ruby 2.2.5

aselder avatar May 18 '16 21:05 aselder