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

match_font crashes R #15

Closed
nathangiang opened this issue Oct 20, 2019 · 29 comments
Closed

match_font crashes R #15

nathangiang opened this issue Oct 20, 2019 · 29 comments

Comments

@nathangiang
Copy link

nathangiang commented Oct 20, 2019

In running match_font('sans', italic = TRUE), R crashes. It just abruptly closes, and if I run in RStudio, it aborts the session by saying R encountered a fatal error. I am on windows 10 and am running R 3.6.1.

Edit: In fact, it crashes on every single function used in systemfonts.

@thomasp85
Copy link
Member

I cannot reproduce this. Can I get you to try on another windows computer to see if it is specific to your machine..?

@davidgohel
Copy link

HI,

I am not able to reproduce neither but I some users are facing the same issue.

systemfonts::system_fonts()

# A tibble: 579 x 9`
   path                                                                                            index name                family         style    weight width      italic monospace`
 <chr>                                                                                           <int> <chr>               <chr>          <chr>     <fct>  <fct>      <lgl>  <lgl>    
1 /Library/Fonts/ITFDevanagari.ttc                                                                    1 ITFDevanagari-Bold  ITF** Devanagari Bold      bold   normal     FALSE  FALSE    
2 /System/Library/Assets/com_apple_MobileAsset_Font5/940db29a0ab220999d9a1dbe3eb0819a718057b5.as…     0 STLibianSC-Regular  Libian SC      Regular   normal normal     FALSE  FALSE    
3 /Library/Fonts/SignPainter.ttc                                                                      0 SignPainter-HouseS… SignPainter    HouseScr… normal semiconde… FALSE  FALSE    
4 /System/Library/Assets/com_apple_MobileAsset_Font5/5e1b464ce3451847af214d857f01a4a4ca6dfbdb.as…**     4 STYuanti-SC-Light   Yuanti SC      Light     light  normal     FALSE  FALSE    
 5 /System/Library/Assets/com_apple_MobileAsset_Font5/89398fcde72f2206bbc162797eeb609f3f61fbd8.as…     1 NanumPen            Nanum Pen Scr… Regular   normal normal     FALSE  FALSE    
6 /Library/Fonts/Kannada Sangam MN.ttc                                                                1 KannadaSangamMN-Bo… Kannada Sanga… Bold      bold   normal     FALSE  FALSE    
7 /Library/Fonts/Damascus.ttc                                                                         0 Damascus            Damascus       Regular   normal normal     FALSE  FALSE    
 8 /System/Library/Assets/com_apple_MobileAsset_Font5/ee22bff5339ff376c79ca4c0814d49d3cfa`cb68e.as…     1 NanumMyeongjoBold   Nanum Myeongjo Bold      bold   normal     FALSE  FALSE    
9 /System/Library/Assets/com_apple_MobileAsset_Font5/5cacaa007b5810b9f023061183336403b9d5c20b.as…     0 NanumGothic         Nanum Gothic   Regular   normal normal     FALSE  FALSE    
10 /System/Library/Fonts/KohinoorBangla.ttc                                                            3 KohinoorBangla-Bold Kohinoor Bang… Bold      bold   normal     FALSE  FALSE    
# … with 569 more rows

 *** caught segfault ***
address 0x160, cause 'memory not mapped'

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace`

A sessionInfo() of an user that has this issue.

> sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.3

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] gdtools_0.2.1   flextable_0.5.8 Rcpp_1.0.3     

loaded via a namespace (and not attached):
 [1] digest_0.6.24     R6_2.4.1          magrittr_1.5      evaluate_0.14    
 [5] zip_2.0.4         rlang_0.4.4       uuid_0.1-2        data.table_1.12.8
 [9] xml2_1.2.2        rmarkdown_2.1     tools_3.6.2       officer_0.3.6    
[13] xfun_0.12         compiler_3.6.2    systemfonts_0.1.1 base64enc_0.1-3  
[17] htmltools_0.4.0   knitr_1.28

@thomasp85
Copy link
Member

@davidgohel so it prints the nibble, but then crashes? That is extremely weird as it indicates that the compiled code has finished executing...

Can I get you to try with the devel version and report back? quite a lot has changed...

@davidgohel
Copy link

It seems so. I will ask the user and see if he can help as for me everything is OK. Thanks!

@davidgohel
Copy link

davidgohel commented Mar 12, 2020

@NicolasStefaniak Sorry to bother. As you are facing that issue and it's difficult to reproduce, would you be ok to install the latest devel version of systemfonts and then re run systemfonts::system_fonts()?

@NicolasStefaniak
Copy link

NicolasStefaniak commented Mar 13, 2020

Dear Thomas, dear David,
I made a first attempt yesterday :
devtools::install_github("r-lib/systemfonts")

It worked well on windows but the installation failed on macbook pro, with macOS Catalina. I'm going to try again tonight or tomorrow.
Best

@davidgohel
Copy link

Nicolas, use this command instead :)

devtools::install_github("r-lib/systemfonts")

@NicolasStefaniak
Copy link

Nicolas, use this command instead :)

devtools::install_github("r-lib/systemfonts")

sorry, it was what I have tested. I will try again.

@NicolasStefaniak
Copy link

NicolasStefaniak commented Mar 15, 2020

Dear all,
the behavior of the MacBook is quite weird.
I have deleted the old version of systemfonts and I tried :
devtools::install_github("r-lib/systemfonts")

The installation failed. Here is the error message :

ownloading GitHub repo r-lib/systemfonts@master
   checking DESCRIPTION meta-information ...s/by1q1ldn68zb67g5g3x4_lf00000gn/T/Rtmpkct5k6/remotes218c640b076b/r-lib-systemfonts-25d19d8/DESCRIPTION’ ...
* installing *source* package ‘systemfonts’ ...
Using PKG_CFLAGS=
Using PKG_LIBS=-lfreetype
** using staged installation
<stdin>:1:10: fatal error: 'ft2build.h' file not found
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because freetype2 was not found. Try installing:
 * deb: libfontconfig1-dev (Debian, Ubuntu, etc)
 * rpm: fontconfig-devel (Fedora, EPEL)
 * csw: fontconfig_dev (Solaris)
 * brew: freetype (OSX)
If freetype2 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a freetype2.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
#include <ft2build.h>
         ^~~~~~~~~~~~
1 error generated.
ERROR: configuration failed for package ‘systemfonts’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/systemfonts’
Erreur : Failed to install 'systemfonts' from GitHub:
  (converti depuis l'avis) installation of package ‘/var/folders/_s/by1q1ldn68zb67g5g3x4_lf00000gn/T//Rtmpkct5k6/file218c1014351d/systemfonts_0.1.1.9000.tar.gz’ had non-zero exit status

Thus, I checked whether freetype2 was installed. It was installed and I added the pack-config folder
Capture d’écran 2020-03-15 à 11 20 42
I also added the 'freetype2.pc'in the pack-config folder. I tried again to install systemfonts but it anew fails with the same error message.
Next, I installed the cran version of systemfonts.
I tried to check whether R crashes and it was the case when I launch the GUI but it was not the case when I launch R from the terminal.

Thus, the solution is to launch R from the terminal. However, it does not explain why R crashes when it is launched as a GUI app. (I hope that I am clear, and if it is not the case, just let me know)
Capture d’écran 2020-03-15 à 11 29 04
Capture d’écran 2020-03-15 à 11 31 04

@thomasp85
Copy link
Member

How has freetype been installed? With Brew?

@NicolasStefaniak
Copy link

@thomasp85
Copy link
Member

hmm... that is weird

@thomasp85
Copy link
Member

@NicolasStefaniak
Copy link

NicolasStefaniak commented Mar 21, 2020

I can install this version but the behavior is exactly the same : it works when I launch R from Terminal but not when I use the R GUI.
sessionInfo()

R version 3.6.2 (2019-12-12)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] fr_FR.UTF-8/fr_FR.UTF-8/fr_FR.UTF-8/C/fr_FR.UTF-8/fr_FR.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] systemfonts_0.1.1.9000

loaded via a namespace (and not attached):
[1] compiler_3.6.2

@thomasp85
Copy link
Member

Well, that at least confirms that the issue has not yet been resolved.

Can you call system_fonts() without a crash? What do you get?

@NicolasStefaniak
Copy link

It depends if R is launched from Terminal or from R GUI. From terminal, it works well, from R GUI, R crashes.
systemfonts::system_fonts()

# A tibble: 579 x 9`
   path                                                                                            index name                family         style    weight width      italic monospace`
 <chr>                                                                                           <int> <chr>               <chr>          <chr>     <fct>  <fct>      <lgl>  <lgl>    
1 /Library/Fonts/ITFDevanagari.ttc                                                                    1 ITFDevanagari-Bold  ITF** Devanagari Bold      bold   normal     FALSE  FALSE    
2 /System/Library/Assets/com_apple_MobileAsset_Font5/940db29a0ab220999d9a1dbe3eb0819a718057b5.as…     0 STLibianSC-Regular  Libian SC      Regular   normal normal     FALSE  FALSE    
3 /Library/Fonts/SignPainter.ttc                                                                      0 SignPainter-HouseS… SignPainter    HouseScr… normal semiconde… FALSE  FALSE    
4 /System/Library/Assets/com_apple_MobileAsset_Font5/5e1b464ce3451847af214d857f01a4a4ca6dfbdb.as…**     4 STYuanti-SC-Light   Yuanti SC      Light     light  normal     FALSE  FALSE    
 5 /System/Library/Assets/com_apple_MobileAsset_Font5/89398fcde72f2206bbc162797eeb609f3f61fbd8.as…     1 NanumPen            Nanum Pen Scr… Regular   normal normal     FALSE  FALSE    
6 /Library/Fonts/Kannada Sangam MN.ttc                                                                1 KannadaSangamMN-Bo… Kannada Sanga… Bold      bold   normal     FALSE  FALSE    
7 /Library/Fonts/Damascus.ttc                                                                         0 Damascus            Damascus       Regular   normal normal     FALSE  FALSE    
 8 /System/Library/Assets/com_apple_MobileAsset_Font5/ee22bff5339ff376c79ca4c0814d49d3cfa`cb68e.as…     1 NanumMyeongjoBold   Nanum Myeongjo Bold      bold   normal     FALSE  FALSE    
9 /System/Library/Assets/com_apple_MobileAsset_Font5/5cacaa007b5810b9f023061183336403b9d5c20b.as…     0 NanumGothic         Nanum Gothic   Regular   normal normal     FALSE  FALSE    
10 /System/Library/Fonts/KohinoorBangla.ttc                                                            3 KohinoorBangla-Bold Kohinoor Bang… Bold      bold   normal     FALSE  FALSE    
# … with 569 more rows

 *** caught segfault ***
address 0x160, cause 'memory not mapped'

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

@thomasp85
Copy link
Member

So, it begins printing the output, but then crashes afterwards?

What happens if you don’t print it but saves it in a variable instead?

@NicolasStefaniak
Copy link

it crashes without output

@thomasp85
Copy link
Member

That is an incredibly weird bug

@thomasp85
Copy link
Member

@NicolasStefaniak can I get you to test with this version: https://drive.google.com/file/d/1_qgYvSzQcGVSSGot1pFvJKHu1ITktLKK/view?usp=sharing

It's a bit fixing in the blind, but I just want to test before we go deeper

@NicolasStefaniak
Copy link

  • thread Use Makevars to compile on various systems #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x5f2b60997260)
    • frame #0: 0x00007fff63e8464c libobjc.A.dylibobjc_release + 28 frame #1: 0x00007fff63e8547c libobjc.A.dylib(anonymous namespace)::AutoreleasePoolPage::pop(void*) + 710
      frame Can't compile on Linux #2: 0x00007fff396aad9a CoreFoundation_CFAutoreleasePoolPop + 22 frame #3: 0x00007fff3b9250b3 Foundation-[NSAutoreleasePool release] + 144
      frame Setup proper configure script #4: 0x0000000109b42e07 Rrun_REngineRmainloop + 327 frame #5: 0x0000000109b36e31 R-[REngine runREPL] + 225
      frame tweak travis #6: 0x0000000109b25ba1 Rmain + 817 frame #7: 0x00007fff6565f3d5 libdyld.dylibstart + 1
      frame Add author and a comment #8: 0x00007fff6565f3d5 libdyld.dylib`start + 1

@thomasp85
Copy link
Member

@NicolasStefaniak Just to be sure - the crash happens with RStudio as well?

@thomasp85
Copy link
Member

@NicolasStefaniak I'm pretty sure this is fixed now.

I'm closing, but feel free to reopen if the issue persists

@z3tt
Copy link

z3tt commented Mar 31, 2023

Hi @thomasp85, since moving from Windows to a Mac I have several issues when working with typefaces and {systemfonts} in R and RStudio.

My problem is the same as discussed above. I have just installed the latest dev version, updated R and RStudio, and checked that the font files are properly installed. But the crash still happens, either after calling system_fonts() or register_font(). Other commands such font_info() do work.

I have the feeling it is related to the installed font files (which work seamlessly in all other applications) but can't figure out how to fix this. I even have removed all my personal typefaces but R is still crashing. Any input is highly appreciated.

@thomasp85
Copy link
Member

do you see the same difference between guy and terminal as described above?

@z3tt
Copy link

z3tt commented Mar 31, 2023

I haven't tried the terminal yet but in the meantime I was able to figure out that variable font files seem to cause the issue. Not sure if it was causing the original issue (crashing R when calling e.g. system_fonts()) but it crashed R every time I tried using such a font in element_text() (note: it only threw a warning when passing it inside a text geom via fontface strangely). The fonts have been installed both ways, as static and variable files. Removing the variable ones solved the issues for now.

@z3tt
Copy link

z3tt commented May 1, 2024

Hey @thomasp85, I am again facing issues with the systemfonts package on my Mac, similar to the behavior described in the original issue. It also crashes without any custom fonts installed in the R GUI (and in Rstudio and VS Code as well).

> systemfonts::system_fonts()

 *** caught segfault ***
address 0x0, cause 'invalid permissions'

Traceback:
 1: system_fonts_c()
 2: systemfonts::system_fonts()

No output is printed, it crashes immediately. The same happens when saving the output to an object. Interestingly, systemfonts::match_font() works but loading the systemfonts table or registering a variant lead to a crash. Also, custom fonts work when using ggplot2 without any explicit call to systemfonts. (However, geoms from the geomtextpath packages, which features systemfonts as dependency, does crash it -> see below).

Running systemfonts code in lldb results in the following:

> systemfonts::system_fonts()
Process 20760 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x000000019bcca8e4 CoreFoundation`CFArrayGetCount + 8
CoreFoundation`CFArrayGetCount:
->  0x19bcca8e4 <+8>:  ldr    x9, [x0]
    0x19bcca8e8 <+12>: adrp   x10, 370649
    0x19bcca8ec <+16>: ldr    x10, [x10, #0xd70]
    0x19bcca8f0 <+20>: bic    x8, x9, x10
Target 0: (R) stopped.

What I have tried so far:

  • fresh install of both R and Rstudio
  • fresh install of the systemfonts package from CRAN and GitHub
  • removing all custom font files from the directory
  • checking the library paths (seem to be okay)

Any idea what is going on?

(Also, let me know if I should turn this into a new issue instead of commenting on this old one here.)


When loading the geomtextpath package, it also crashes as it ultimatively calls system_fonts():

> library(geomtextpath)

 *** caught segfault ***
address 0x0, cause 'invalid permissions'

Traceback:
 1: system_fonts_c()
 2: systemfonts::system_fonts()
 3: nrow(systemfonts::system_fonts())
 4: fun(libname, pkgname)
 5: doTryCatch(return(expr), name, parentenv, handler)
 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 7: tryCatchList(expr, classes, parentenv, handlers)
 8: tryCatch(fun(libname, pkgname), error = identity)
 9: runHook(".onLoad", env, package.lib, package)
10: loadNamespace(package, lib.loc)
11: doTryCatch(return(expr), name, parentenv, handler)
12: tryCatchOne(expr, names, parentenv, handlers[[1L]])
13: tryCatchList(expr, classes, parentenv, handlers)
14: tryCatch({    attr(package, "LibPath") <- which.lib.loc    ns <- loadNamespace(package, lib.loc)    env <- attachNamespace(ns, pos = pos, deps, exclude, include.only)}, error = function(e) {    P <- if (!is.null(cc <- conditionCall(e)))         paste(" in", deparse(cc)[1L])    else ""    msg <- gettextf("package or namespace load failed for %s%s:\n %s",         sQuote(package), P, conditionMessage(e))    if (logical.return && !quietly)         message(paste("Error:", msg), domain = NA)    else stop(msg, call. = FALSE, domain = NA)})
15: library(geomtextpath)

Session info:

#> R version 4.4.0 (2024-04-24)
#> Platform: aarch64-apple-darwin20
#> Running under: macOS Ventura 13.6.4
#> 
#> Matrix products: default
#> BLAS:   /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRblas.0.dylib 
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0
#> 
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#> 
#> time zone: Europe/Berlin
#> tzcode source: internal
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> loaded via a namespace (and not attached):
#>  [1] digest_0.6.35     fastmap_1.1.1     xfun_0.43         glue_1.7.0       
#>  [5] knitr_1.46        htmltools_0.5.8.1 rmarkdown_2.26    lifecycle_1.0.4  
#>  [9] cli_3.6.2         reprex_2.1.0      withr_3.0.0       compiler_4.4.0   
#> [13] rstudioapi_0.16.0 tools_4.4.0       evaluate_0.23     yaml_2.3.8       
#> [17] rlang_1.1.3       fs_1.6.4

@thomasp85
Copy link
Member

@z3tt yes, please open a new issue

@z3tt
Copy link

z3tt commented May 1, 2024

This can be closed as the recent discussion was moved to a new issue #113.

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

5 participants