JetBrains / markdown

Markdown parser written in kotlin
Apache License 2.0
706 stars 78 forks source link

Segfault when running native release executables #130

Closed ajalt closed 1 year ago

ajalt commented 1 year ago

When running the basic code from the readme on a native target:

val src = "Some *Markdown*"
val flavour = GFMFlavourDescriptor()
val parsedTree = MarkdownParser(flavour).buildMarkdownTreeFromString(src)
val html = HtmlGenerator(src, parsedTree, flavour).generateHtml()

The code runs correctly in debug builds (e.g. gradlew runDebugExcutableNative), but segfaults when running a release binary (e.g. gradlew runDebugExcutableNative)

You can reproduce this on macos, linuxX64, and mingwX64. Tested on library version 0.4.1 and 0.5.1, Kotlin 1.9.10 and 1.9.10. All versions reproduce the segfault.

See this comment for an example of valgrind output for the segfault.

FirstTimeInForever commented 1 year ago

@ajalt Thank you for the report. I was able to reproduce the issue and working on the fix now.

FirstTimeInForever commented 1 year ago

@ajalt It seems that there is a bug/oddity in the native backend that affected the generated binaries after upgrading to the Kotlin 1.9.0. I've added a workaround for this and it seems to work. Please try the 0.5.2-SNAPSHOT (add maven("https://oss.sonatype.org/content/repositories/snapshots/") to the repositories).

ajalt commented 1 year ago

Yes, that seems to fix the issue for me. Thank you for the quick fix!

FirstTimeInForever commented 1 year ago

I've released the 0.5.2 version with the fix. Please update :)

lppedd commented 1 year ago

Is this strange Native behavior logged in some YouTrack issue?