Closed confact closed 4 years ago
This seems to be a problem with freeing the pointers of nodes in the underlying C library while Crystal garbage-collects an instance of Cmark::Node.
Can you provide more details (which version of Crystal are you using, environment, etc)?
Can you also provide a minimal example which reproduces the issue?
Hi @amauryt, I have created a public repo that gives this error: https://github.com/confact/cmark-bug-test
There you can see I am using 0.34 of crystal. My operative system is Arch Linux.
You run the Lucky app like this:
The class that is calling cmark is ./src/pages/faq/data_privacy_page.cr
Hey @confact. I cloned the app and followed your instructions (you missed a "yarn install" :wink:) but I am unable to reproduce the issue. I'm constantly reloading on the browser the page you indicated and the Markdown is rendered without a problem. I am using MacOS though.
Can you try your app on a different OS? Or perhaps you have different settings or do something different?
I am also this library and my project once deployed on Heroku crashes with Invalid memory access (signal 11) at address 0x7fbec3d59270
whenever I access a page that uses this library.
It works great on my Macbook Pro, so this is probably why @amauryt is not getting the error.
Thank you for confirming the issue @snadon. It seems that I need to fix node garbage collection for Linux, but first I need more information.
Cmark
to create/render the MD?Thank you for confirming the issue @snadon. It seems that I need to fix node garbage collection for Linux, but first I need more information.
* Are you also using Lucky to render your webpage with MD content, or another framework?
Yes. Here's the code for that page:
require "cmark"
class Home::IndexEnSlug < BrowserAction
include Auth::AllowGuests
get "/en/:slug" do
lang = AppLang::EN.value
doc = DocQuery.new
.lang(lang)
.slug(slug)
.first?
unless doc.nil?
options = Cmark::Option.flags(Nobreaks, ValidateUTF8)
extensions = Cmark::Extension.flags(Table)
doc.content = Cmark.document_to_html(doc.content, options, extensions)
html ShowPage, lang: lang, doc: doc
else
html Errors::ShowPage, message: "Not Found!", status: 404
end
end
end
class Docs::ShowPage < MainLayout
needs doc : Doc
quick_def page_title, "Page ##{doc.id}"
def content
link "← Back", Docs::Index
h1 "Page (#{AppLang.new(doc.lang)}) ##{doc.id}"
render_actions
render_doc_fields
end
def render_actions
section do
link "Edit", Docs::Edit.with(doc.id), class: "button mr-2"
link "Delete",
Docs::Delete.with(doc.id),
data_confirm: "Are you sure?",
class: "button button-danger"
end
end
def render_doc_fields
div do
raw doc.content
end
end
end
* Just to confirm, the page crashes all the time, right? Or only after a few reloads as in the first report?
Lately it was all the time, even after purging (heroku repo:purge_cache -a appname
). However, IIRC, it was intermittent at the beginning of the project.
* Is your stack on Heroku v18 (Ubuntu 18), v16 or a container?
heroku-18
Thanks for the info. This should be already fixed on master, please do a shards update
. Otherwise feel free to reopen this issue.
I am using this in lucky to generate content for pages from markdown files.
I get this error after reloading the markdown page 2-4 times:
Is it something I have to think about when using this?