Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3 cannot read pdf files #105

Closed
Napping-Lunar opened this issue Jan 27, 2022 · 11 comments
Closed

v3 cannot read pdf files #105

Napping-Lunar opened this issue Jan 27, 2022 · 11 comments

Comments

@Napping-Lunar
Copy link

@Napping-Lunar Napping-Lunar commented Jan 27, 2022

I use Fedora Linux so I'll provide the steps to reproduce this issue.

  1. Take a fresh install of Fedora Linux 35 (Workstation Edition) or use a live USB with enough space.
  2. Install R (v4.1.2), R-magick (v2.7.3), R-pdftools (v3.0.1), through dnf:
    sudo dnf install R R-magick R-pdftools
  3. Run R and try to import a pdf, as demonstrated in the rOpenSci magick intro page:
library(magick)
manual <- image_read_pdf('https://cloud.r-project.org/web/packages/magick/magick.pdf', density = 72)
  1. Receive the following error, aborting R:
/usr/include/c++/11/bits/basic_string.h:1136: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::back() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference = char&]: Assertion '!empty()' failed.

This also occurs when installing the magick (v2.7.2) and pdftools (v3.0.0) R packages instead from the RStudio repository (requires installing ImageMagick-c++-devel libcurl-devel libjpeg-turbo-devel poppler-cpp-devel via dnf first):

options(repos = c(REPO_NAME = "https://packagemanager.rstudio.com/all/2021-05-07+Y3JhbiwyOjE3NTA3NTI7OUM2OTYyMkM"))
install.packages(c("magick", "pdftools"))
# Select "yes" twice when prompted to create personal library
manual <- image_read_pdf('https://cloud.r-project.org/web/packages/magick/magick.pdf', density = 72)

This does not happen with magick v2.7.2 and pdftools v2.3.1 (replace the REPO_NAME with options(repos = c(REPO_NAME = "https://packagemanager.rstudio.com/all/2021-05-03+Y3JhbiwyOjE3NTA3NTI7NkMwNDVBMjE"))).

Unfortunately the error message is too opaque for me to identify the issue further, so any help would be much appreciated!

@jeroen
Copy link
Member

@jeroen jeroen commented Feb 22, 2022

It looks like the build of R-pdftools on Fedora 35 is broken. They probably compiled R-pdftools against another version of libpoppler than the one that is currently in F-35.

@Enchufa2 can you have a look? Here is a minimal example:

pdftools::pdf_info('https://cloud.r-project.org/web/packages/magick/magick.pdf')

@Enchufa2
Copy link

@Enchufa2 Enchufa2 commented Feb 22, 2022

Unless I missed something, builds are fine (pinging @QuLogic, the maintainer of this package). Line 1136 of basic_string.h is this:

__glibcxx_assert(!empty());

Fedora enables -D_GLIBCXX_ASSERTIONS to catch this kind of thing, which denotes a bug in the package.

@Enchufa2
Copy link

@Enchufa2 Enchufa2 commented Feb 22, 2022

Here's the bug:

if(str.back() == '\f')

This function shall not be called on empty strings. [ref]

@jeroen
Copy link
Member

@jeroen jeroen commented Feb 22, 2022

Here's the bug:

Thanks! So this issue is fixed if we replace that line with if(str.length() && str.back()) ?

@Enchufa2
Copy link

@Enchufa2 Enchufa2 commented Feb 22, 2022

Correct.

@jeroen jeroen closed this as completed in fa9ead6 Feb 22, 2022
@jeroen
Copy link
Member

@jeroen jeroen commented Feb 22, 2022

OK I'll add that. Doesn't Fedora run CMD check when building R-pdftools ? This should have triggered in a unit test?

@QuLogic
Copy link

@QuLogic QuLogic commented Feb 22, 2022

It does and it should have, but whoever bumped to 3.0.1 turned them off to bootstrap and never remembered to enable them, or didn't report a bug to either of us.

@Enchufa2
Copy link

@Enchufa2 Enchufa2 commented Feb 22, 2022

According to the build history, spot updated the package, triggered a bootstrap rebuild and a normal one, which failed. He was probably too busy rebuilding R and the whole stack of packages and forgot to look into it.

@jeroen
Copy link
Member

@jeroen jeroen commented Feb 22, 2022

OK well thanks for helping me debugging. If you run into any other crashes on Fedora with one of my packages I would love to hear about it of course.

@QuLogic
Copy link

@QuLogic QuLogic commented Feb 23, 2022

Well yes, I was trying to avoid naming names...

In any case, I've submitted an update with the fix backported.

@Enchufa2
Copy link

@Enchufa2 Enchufa2 commented Feb 23, 2022

Well yes, I was trying to avoid naming names...

Not pointing fingers here. Quite the opposite: rebuilding R and the entire stack is a pretty demanding task, as you know, so it's perfectly understandable that something like this slipped through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants