r-lib / commonmark

High Performance CommonMark and Github Markdown Rendering in R
https://docs.ropensci.org/commonmark/
Other
88 stars 11 forks source link

commonmark_html() crashes or fails on RStudio Server on CentOS #12

Closed yutannihilation closed 5 years ago

yutannihilation commented 5 years ago

I don't know why, but commonmark_html() and commonmark_xml() doesn't work well on the console of RStudio Server on CentOS 7.

More precisely, if I install commonmark package 1.6 and run commonmark::markdown_html("## foo"),

Note that, it returns the correct result ("<h2>foo</h2>\n") if I run the code

How to reproduce

  1. Run CentOS Docker image
    docker run -p 8787:8787 -it --rm centos:7 bash
  2. Install and run RStudio Server
    
    # Download RPM (`1.1.463` is the stable version)
    curl -o rstudio.rpm https://download2.rstudio.org/rstudio-server-rhel-1.1.463-x86_64.rpm
    yum install rstudio.rpm

Add rstudio user

useradd rstudio passwd rstudio

Launch RStudio Server

/usr/lib/rstudio-server/bin/rserver

3. Browse to `http://localhost:8787` and login
4. Install commonmark package and run this code
```r
commonmark::markdown_html("## foo")
jeroen commented 5 years ago

Thanks for the detailed report. This might indicate a symbol conflict with something built in rstudio. Will investigate soon.

yutannihilation commented 5 years ago

This might indicates a symbol conflict with something built in rstudio.

Thanks. I think I don't have enough knowledge to understand the problem... does that mean this is a issue on commonmark's side? Or, should I file this to rstudio's repo?

jeroen commented 5 years ago

This is very strange, indeed. I can reproduce the problem with the latest rstudio-server on CentOS and Fedora, but not on Ubuntu/Debian.

Program received signal SIGABRT, Aborted.
0x00007ff46cf8e277 in raise () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ff46cf8e277 in raise () from /lib64/libc.so.6
#1  0x00007ff46cf8f968 in abort () from /lib64/libc.so.6
#2  0x00007ff46cfd0d37 in __libc_message () from /lib64/libc.so.6
#3  0x00007ff46cfd75e4 in malloc_printerr () from /lib64/libc.so.6
#4  0x00007ff46cfde079 in realloc () from /lib64/libc.so.6
#5  0x00007ff4434e37c9 in xrealloc (ptr=<optimized out>, size=<optimized out>) at cmark/cmark.c:27
#6  0x00007ff443503b3a in cmark_strbuf_grow (buf=0x7fffdbad9f50, target_size=<optimized out>) at cmark/buffer.c:58
#7  0x00007ff443503d4a in S_strbuf_grow_by (add=4, buf=0x7fffdbad9f50) at cmark/buffer.c:36
#8  cmark_strbuf_put (buf=buf@entry=0x7fffdbad9f50, data=data@entry=0x7fffdbad9fb0 "</h2", len=4) at cmark/buffer.c:113
#9  0x00007ff443503da7 in cmark_strbuf_puts (buf=buf@entry=0x7fffdbad9f50, string=string@entry=0x7fffdbad9fb0 "</h2") at cmark/buffer.c:120
#10 0x00007ff443505d0c in S_render_node (options=0, ev_type=<optimized out>, node=0x53e4ac0, renderer=0x7fffdbad9f70) at cmark/html.c:182
#11 cmark_render_html_with_mem (root=root@entry=0x53d2000, options=options@entry=0, extensions=<optimized out>, extensions@entry=0x0, 
    mem=<optimized out>) at cmark/html.c:452
#12 0x00007ff443505ff8 in cmark_render_html (root=root@entry=0x53d2000, options=options@entry=0, extensions=extensions@entry=0x0)
    at cmark/html.c:432
#13 0x00007ff4434e36e5 in print_document (width=0, options=0, writer=<optimized out>, document=0x53d2000) at wrapper.c:27
#14 R_render_markdown (text=<optimized out>, format=0x9166770, sourcepos=<optimized out>, hardbreaks=<optimized out>, 
jeroen commented 5 years ago

Should be fixed in master now, thanks @kevinushey.

For future reference: this was the same problem as https://github.com/ropensci/hunspell/issues/21. The package includes a lib that defines symbols which conflict with things in rstudio. Somehow CentOS / Fedora is more sensitive about this than other systems.

jeroen commented 5 years ago

Fixed an on its way to CRAN. Thanks again for reporting this!

yutannihilation commented 5 years ago

Oh, thanks for fixing so quickly!!