carpentries / sandpaper

User Interface for The Carpentries Workbench
https://carpentries.github.io/sandpaper
Other
41 stars 26 forks source link

segfault on sandpaper::serve() #588

Closed ns-rse closed 1 month ago

ns-rse commented 1 month ago

I've encountered a segmentation fault when attempting to render pages under R-4.4.0.

I've attempted to identify where this occurs using valgrind

❱ R -d valgrind
==48610== Memcheck, a memory error detector
==48610== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==48610== Using Valgrind-3.23.0 and LibVEX; rerun with -h for copyright info
==48610== Command: /usr/lib64/R/bin/exec/R
==48610== 

R version 4.4.0 (2024-04-24) -- "Puppy Cup"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[Previously saved workspace restored]

> 
> sandpaper::serve()
ℹ Rebuilding /home/neil/work/git/hub/ns-rse/git-collaboration
── Validating Fenced Divs ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
── Validating Internal Links and Images ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
! There were errors in 9/250 links and images
◌ Images need alt-text <https://webaim.org/techniques/hypertext/link_text#alt_link>
◌ Avoid single-letter or missing link text <https://webaim.org/techniques/hypertext/link_text#link_length>

episodes/git_hygiene.md:204 [link text too short]: [R](https://www.r-project.org)
episodes/diverging_branches.md:61 [image missing alt-text]: https://mermaid.ink/img/pako:eNqtklFv2yAUhf8KQoq8SSYDbDD4bVqr9WF72tvkF4JxglqbDOOpreX_PkiaKpXadNJmP9j38N1zD9KdoXatgTVcrWY72FCDOQs705usBtlGjSbLQba14atX-12WTr0LKpgvru9t-KY25i6qwU9maQZweuL_slodhVPz87E-tALb1qCBGJUV7QgmDXwdIIgRQXjL3wIo4hWXXUfBh5T34xm38WrQu8gMI_Kj-UTQo_EOtfa3Ha0bLpAUjb8m5Q3yzoXzyTujb90U_sbzRcoCCc1oq81FszfHnluVSBhdCKn-Ry6GaEFYp_C_5-JIFqYSlX7Nqld2eFZ747fmQtQnwwptdFnItBsgqG2Svh86Ew7eu9nN9eerBsIcxmlxeht3fE5kAw_73cAEtcrfJoMlctO-jYt93drgPKzTSudQTcH9eBj0qT4yV1ZtvepP4l4NP52LZafuxmMN6xnewxqVAq8lq-KLZcmpECyHD7DmeM0xZfFqRMr4kUsOHw8WdI1piQvBSMEKLmW1_AHrjxWc?type=png
episodes/diverging_branches.md:80 [image missing alt-text]: https://mermaid.ink/img/pako:eNqtklFv2yAUhf8KQoq8SSYDbDD4bVqr9WF72tvkF4JxglqbDOOpreX_PkiaKpXadNJmP9j38N1zD9KdoXatgTVcrWY72FCDOQs705usBtlGjSbLQba14atX-12WTr0LKpgvru9t-KY25i6qwU9maQZweuL_slodhVPz87E-tALb1qCBGJUV7QgmDXwdIIgRQXjL3wIo4hWXXUfBh5T34xm38WrQu8gMI_Kj-UTQo_EOtfa3Ha0bLpAUjb8m5Q3yzoXzyTujb90U_sbzRcoCCc1oq81FszfHnluVSBhdCKn-Ry6GaEFYp_C_5-JIFqYSlX7Nqld2eFZ747fmQtQnwwptdFnItBsgqG2Svh86Ew7eu9nN9eerBsIcxmlxeht3fE5kAw_73cAEtcrfJoMlctO-jYt93drgPKzTSudQTcH9eBj0qT4yV1ZtvepP4l4NP52LZafuxmMN6xnewxqVAq8lq-KLZcmpECyHD7DmeM0xZfFqRMr4kUsOHw8WdI1piQvBSMEKLmW1_AHrjxWc?type=png
episodes/diverging_branches.md:115 [image missing alt-text]: https://mermaid.ink/img/pako:eNqtk8GOmzAQhl8FWYpoJUxtA8bmVnVX7aE99VZxMcYk1i44NWbVXcS715CyTaIkqtpywuN_vvk9mhmBNLUCBdhsRt1pVwRj6HaqVWERhJXoVRgF4Va7j1bsd-F8a40TTn0wbavdZ1GpRx91dlBT2QXr5_-nzeYQWJNfr-WSGui6CEqAYJqTBiNcgssCDDPMMK3pNQGBNKe8aUjwZvb79khXWdHJndd0PbS9eofhi7IG1vpJ99p0N5QE9t8HYRW0xrjjyjslH8zg_oR54jKBTGakluom7GrZY1QKmZIJ4-J_-MogSXDWCPTvvijkicpZLi-hWqG712ir7FbdsPoLmMNKpgmfZyNwYjuHnlCM46uz8un-_d1fvWM1tLhcyzMoGJKqYb_Lf1l0B9VlCxzKiiX8tJ8n84wgFipLZXLZ6Rn8rFVnD1iZ2FuVnCfkrFNkJoEIeIrn1n7Nx5lcgmXFSzALa2EfZtnkdcO-9rt9X2tnLCjmrY6AGJz5-tzJ9XzQ3GmxtaIFRSMeex_di-6bMSdnUIzgBygwyWOcEoSTDHHMEU8i8AwKwmjMckwYyThllLIpAi8LAcUMYR9KEfU5Wcbx9BO0WV5-?type=png
episodes/diverging_branches.md:256 [image missing alt-text]: https://mermaid.ink/img/pako:eNqtklFv2yAUhf8KQoq8SSYDbDD4bVqr9WF72tvkF4JxglqbDOOpreX_PkiaKpXadNJmP9j38N1zD9KdoXatgTVcrWY72FCDOQs705usBtlGjSbLQba14atX-12WTr0LKpgvru9t-KY25i6qwU9maQZweuL_slodhVPz87E-tALb1qCBGJUV7QgmDXwdIIgRQXjL3wIo4hWXXUfBh5T34xm38WrQu8gMI_Kj-UTQo_EOtfa3Ha0bLpAUjb8m5Q3yzoXzyTujb90U_sbzRcoCCc1oq81FszfHnluVSBhdCKn-Ry6GaEFYp_C_5-JIFqYSlX7Nqld2eFZ747fmQtQnwwptdFnItBsgqG2Svh86Ew7eu9nN9eerBsIcxmlxeht3fE5kAw_73cAEtcrfJoMlctO-jYt93drgPKzTSudQTcH9eBj0qT4yV1ZtvepP4l4NP52LZafuxmMN6xnewxqVAq8lq-KLZcmpECyHD7DmeM0xZfFqRMr4kUsOHw8WdI1piQvBSMEKLmW1_AHrjxWc?type=png
episodes/diverging_branches.md:290 [image missing alt-text]: https://mermaid.ink/img/pako:eNqtk02PmzAQhv8KshTRSjH1Bxiba1v10lN7q7gYYxJrF5was-ou4r_XziYrdpVEK7Wc8DvvPB7PaGagbKtBBTab2QzGV8mc-r3udVolaSNHnW6TdGf8NycP-zRGnfXS68-2743_Lht9H1TvJr3UQ3L-wv-y2TwL5-SXsDqmJqatkhogmJekwwjX4LIBwwJzzFp2zUAgK5noOpJ8iPV-XPkaJwe1D55hhG7UnzB80s7C1jyY0dhhTdxrdWcn_y7v-nYKuSpIq_T_gBWQUFx0El2C9dIML2qv3U7f4J-AJWxUTkXsbuLlLkoPKMPZhW6fwj90bOKNHhI4_p6k09BZ628--qpz_eQccq0oF_LfUQwKqkteqmuGEqqGU_G6vWsDh1jqIlf0cjHHCYBrM3hT4wkpYCMFRQS9mQCJoHoAWxAwAdyGFZwjugbH9atBtLbS3UXjEnzToQ1797U13jpQxY3bAjl5-_NxUOfzs-eLkTsne1B18n4M6kEOv6x9dQbVDP6ACpMywzlBmBZIYIEE3YJHUBHOMl5iwkkhGGeML1vwdCSgjCMcpByxkFMUAi9_ARUBQVQ?type=png
episodes/diverging_branches.md:415 [image missing alt-text]: https://mermaid.ink/img/pako:eNqtklFv2yAUhf8KQoq8SSYDbDD4bVqr9WF72tvkF4JxglqbDOOpreX_PkiaKpXadNJmP9j38N1zD9KdoXatgTVcrWY72FCDOQs705usBtlGjSbLQba14atX-12WTr0LKpgvru9t-KY25i6qwU9maQZweuL_slodhVPz87E-tALb1qCBGJUV7QgmDXwdIIgRQXjL3wIo4hWXXUfBh5T34xm38WrQu8gMI_Kj-UTQo_EOtfa3Ha0bLpAUjb8m5Q3yzoXzyTujb90U_sbzRcoCCc1oq81FszfHnluVSBhdCKn-Ry6GaEFYp_C_5-JIFqYSlX7Nqld2eFZ747fmQtQnwwptdFnItBsgqG2Svh86Ew7eu9nN9eerBsIcxmlxeht3fE5kAw_73cAEtcrfJoMlctO-jYt93drgPKzTSudQTcH9eBj0qT4yV1ZtvepP4l4NP52LZafuxmMN6xnewxqVAq8lq-KLZcmpECyHD7DmeM0xZfFqRMr4kUsOHw8WdI1piQvBSMEKLmW1_AHrjxWc?type=png
episodes/diverging_branches.md:417 [image missing alt-text]: https://mermaid.ink/img/pako:eNqtk8GOmzAQhl8FWYpoJUxtA8bmVnVX7aE99VZxMcYk1i44NWbVXcS715CyTaIkqtpywuN_vvk9mhmBNLUCBdhsRt1pVwRj6HaqVWERhJXoVRgF4Va7j1bsd-F8a40TTn0wbavdZ1GpRx91dlBT2QXr5_-nzeYQWJNfr-WSGui6CEqAYJqTBiNcgssCDDPMMK3pNQGBNKe8aUjwZvb79khXWdHJndd0PbS9eofhi7IG1vpJ99p0N5QE9t8HYRW0xrjjyjslH8zg_oR54jKBTGakluom7GrZY1QKmZIJ4-J_-MogSXDWCPTvvijkicpZLi-hWqG712ir7FbdsPoLmMNKpgmfZyNwYjuHnlCM46uz8un-_d1fvWM1tLhcyzMoGJKqYb_Lf1l0B9VlCxzKiiX8tJ8n84wgFipLZXLZ6Rn8rFVnD1iZ2FuVnCfkrFNkJoEIeIrn1n7Nx5lcgmXFSzALa2EfZtnkdcO-9rt9X2tnLCjmrY6AGJz5-tzJ9XzQ3GmxtaIFRSMeex_di-6bMSdnUIzgBygwyWOcEoSTDHHMEU8i8AwKwmjMckwYyThllLIpAi8LAcUMYR9KEfU5Wcbx9BO0WV5-?type=png
episodes/diverging_branches.md:419 [image missing alt-text]: https://mermaid.ink/img/pako:eNqtk02PmzAQhv8KshTRSjH1Bxiba1v10lN7q7gYYxJrF5was-ou4r_XziYrdpVEK7Wc8DvvPB7PaGagbKtBBTab2QzGV8mc-r3udVolaSNHnW6TdGf8NycP-zRGnfXS68-2743_Lht9H1TvJr3UQ3L-wv-y2TwL5-SXsDqmJqatkhogmJekwwjX4LIBwwJzzFp2zUAgK5noOpJ8iPV-XPkaJwe1D55hhG7UnzB80s7C1jyY0dhhTdxrdWcn_y7v-nYKuSpIq_T_gBWQUFx0El2C9dIML2qv3U7f4J-AJWxUTkXsbuLlLkoPKMPZhW6fwj90bOKNHhI4_p6k09BZ628--qpz_eQccq0oF_LfUQwKqkteqmuGEqqGU_G6vWsDh1jqIlf0cjHHCYBrM3hT4wkpYCMFRQS9mQCJoHoAWxAwAdyGFZwjugbH9atBtLbS3UXjEnzToQ1797U13jpQxY3bAjl5-_NxUOfzs-eLkTsne1B18n4M6kEOv6x9dQbVDP6ACpMywzlBmBZIYIEE3YJHUBHOMl5iwkkhGGeML1vwdCSgjCMcpByxkFMUAi9_ARUBQVQ?type=png
◉ All files up-to-date; nothing to rebuild!
◉ pandoc found
  version : 3.1.8
  path    : /usr/bin
── Initialising site ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
── Scanning episodes to rebuild ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Writing `instructor/introduction.html`
Writing `introduction.html`
==48610== Invalid read of size 1
==48610==    at 0x484B9A6: strlen (vg_replace_strmem.c:505)
==48610==    by 0x492B1D5: Rf_mkChar (in /usr/lib/R/lib/libR.so)
==48610==    by 0x4973EC3: ??? (in /usr/lib/R/lib/libR.so)
==48610==    by 0x4971DCD: ??? (in /usr/lib/R/lib/libR.so)
==48610==    by 0x4A1B7C6: ??? (in /usr/lib/R/lib/libR.so)
==48610==    by 0x4948595: ??? (in /usr/lib/R/lib/libR.so)
==48610==    by 0x494438D: ??? (in /usr/lib/R/lib/libR.so)
==48610==    by 0x49343BA: Rf_eval (in /usr/lib/R/lib/libR.so)
==48610==    by 0x4932E93: ??? (in /usr/lib/R/lib/libR.so)
==48610==    by 0x4933EDC: ??? (in /usr/lib/R/lib/libR.so)
==48610==    by 0x493733E: R_forceAndCall (in /usr/lib/R/lib/libR.so)
==48610==    by 0x4889916: ??? (in /usr/lib/R/lib/libR.so)
==48610==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==48610== 

 *** caught segfault ***
address (nil), cause 'memory not mapped'

Traceback:
 1: parse(con, keep.source = TRUE, encoding = "UTF-8", srcfile = srcfile)
 2: doTryCatch(return(expr), name, parentenv, handler)
 3: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 4: tryCatchList(expr, classes, parentenv, handlers)
 5: tryCatch(parse(con, keep.source = TRUE, encoding = "UTF-8", srcfile = srcfile),     error = function(e) NULL)
 6: safe_parse(text)
 7: autolink_url(text)
 8: FUN(X[[i]], ...)
 9: vapply(.x, .f, ..., FUN.VALUE = character(1), USE.NAMES = FALSE)
10: map_chr(text, fun, ...)
11: tweak_children(x, xpath_inline, autolink, replace = "contents")
12: downlit::downlit_html_node(html)
13: tweak_page(html, name, pkg = pkg)
14: pkgdown::render_page(pkg, template, data = global_data$instructor$get(),     depth = 1L, path = this_page, quiet = quiet)
15: build_html(template = "chapter", pkg = pkg, nodes = nodes, global_data = page_globals,     path_md = path_md, quiet = quiet)
16: build_episode_html(path_md = abs_md[i], path_src = abs_src[i],     page_back = location["back"], page_forward = location["forward"],     page_progress = progress, date = db$date[i], pkg = pkg, quiet = quiet)
17: build_site(path = path, quiet = quiet, preview = preview, override = override,     slug = slug, built = built)
18: build_lesson(f, preview = FALSE, quiet = quiet)
19: rend(this_path)
20: sandpaper::serve()

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection: 1
R is aborting now ...
==48610== 
==48610== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==48610==    at 0x4D4EE44: __pthread_kill_implementation (pthread_kill.c:44)
==48610==    by 0x4CF6A2F: raise (raise.c:26)
==48610==    by 0x4CF6ADF: ??? (in /usr/lib/libc.so.6)
==48610==    by 0x484B9A5: strlen (vg_replace_strmem.c:505)
==48610== 
==48610== HEAP SUMMARY:
==48610==     in use at exit: 194,192,981 bytes in 356,643 blocks
==48610==   total heap usage: 15,036,292 allocs, 14,679,649 frees, 3,119,519,508 bytes allocated
==48610== 
==48610== LEAK SUMMARY:
==48610==    definitely lost: 76,575 bytes in 309 blocks
==48610==    indirectly lost: 605,383 bytes in 5,490 blocks
==48610==      possibly lost: 4,128,994 bytes in 21,066 blocks
==48610==    still reachable: 189,381,901 bytes in 329,777 blocks
==48610==                       of which reachable via heuristic:
==48610==                         newarray           : 4,264 bytes in 1 blocks
==48610==         suppressed: 128 bytes in 1 blocks
==48610== Rerun with --leak-check=full to see details of leaked memory
==48610== 
==48610== For lists of detected and suppressed errors, rerun with: -s
==48610== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
[1]    48610 segmentation fault (core dumped)  R -d valgrind

...and it looks like its coming from libR.so but I'm unsure.

This is under Arch Linux and I can't downgrade to R-4.3.3 because it has a dependency on icu-74 which is now outdated and downgrading would break a bunch of other dependencies.

froggleston commented 1 month ago

R 4.4.0 is very new, and it seems there's an internal dependency independent of the Workbench that is causing the segfault (this wouldn't be any specific Workbench code that is causing this, rather unmatch builds of lower level libraries outside our control). I suggest waiting until this issue may be resolved in R itself or the library that is conflicting.

tobyhodges commented 1 month ago

I suspect this is related to other segfaults that have been observed elsewhere over the last few days. I have traced those issues to a problem when pkgdown encounters a few mathematical symbols in source Markdown while converting to HTML. Unfortunately, I have not been able to figure out exactly what is going wrong and why, but I am hopeful for a response to the linked issue to move things forward.

froggleston commented 1 month ago

Great find Toby, and thanks for raising the issue with the pkgdown developers!

ns-rse commented 1 month ago

Thanks @tobyhodges and @froggleston I suspected it was lay much deeper than the Workbench but wasn't sure where to look.

EDIT : I see a fix has been merged into downlit already.

tobyhodges commented 1 month ago

As I understand it, the problem will disappear from the lesson builds once the new version of downlit has been approved and published on CRAN.

ns-rse commented 1 month ago

Which shouldn't be too long by the looks of it.

Thanks for identifying the root cause and reporting in the correct place @tobyhodges :+1:

hadley commented 1 month ago

On CRAN now!

tobyhodges commented 1 month ago

Confirming that my lesson builds are now succeeding. I think this issue can be closed.

ns-rse commented 1 month ago

Updated to downlit-0.4.4 and my site that had previously failed builds fine now too.

Thanks @tobyhodges and @hadley :+1: