r-lib / systemfonts

System Native Font Handling in R
https://systemfonts.r-lib.org
Other
92 stars 17 forks source link

systemfonts.dll related crash #90

Closed ZhangAngus closed 2 years ago

ZhangAngus commented 2 years ago

When execute fonts <- system_fonts(), Rgui.exe crashed and exited.

> library(systemfonts)
> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936  LC_CTYPE=Chinese (Simplified)_China.936    LC_MONETARY=Chinese (Simplified)_China.936
[4] LC_NUMERIC=C                               LC_TIME=Chinese (Simplified)_China.936    
system code page: 65001

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

other attached packages:
[1] systemfonts_1.0.3 basetheme_0.1.2  

loaded via a namespace (and not attached):
[1] compiler_4.1.2 tools_4.1.2    pacman_0.5.1   fortunes_1.5-4

So I open system application logs.

Application Name: Rgui.exe, Version: 4.12.15579.0, Application Timestamp: 0x618032ff
Fault Module Name: systemfonts.dll, Version: 0.0.0.0, Application Timestamp: 0x61f508a0
Exception Code: 0xc0000005
Exception Offset: 0x000000000003bc7f
Faulting process id: 0x1d00
Faulting application start time: 0x01d81c33ae271460
Faulting application path: C:\Program Files\R\R-4.1.2\bin\x64\Rgui.exe
Faulting module path: D:\iLibs\r\systemfonts\libs\x64\systemfonts.dll
Report ID: 352ce17a-876d-4010-b87c-8dc4604c63f4

Then I have no clue what happened.

thomasp85 commented 2 years ago

Is this reproducible?

ZhangAngus commented 2 years ago

The problem still exists. Now I delete font by font, and try to figure out whether the key lies in font files.

ZhangAngus commented 2 years ago

I tested font files on another WIN 10 pc, and all worked fine. The error only exists on my new WIN 11 laptop. I try to use WinDbg to find something.

Microsoft (R) Windows Debugger Version 10.0.17763.132 AMD64
Copyright (c) Microsoft Corporation. All rights reserved.

CommandLine: "C:\Program Files\R\R-4.1.2\bin\x64\R.exe"

************* Path validation summary **************
Response                         Time (ms)     Location
OK                                             C:\Windows\symbols
Deferred                                       SRV*
Symbol search path is: C:\Windows\symbols;SRV*
Executable search path is: 
ModLoad: 00000000`00400000 00000000`00421000   image00000000`00400000
ModLoad: 00007ff9`26c40000 00007ff9`26e49000   ntdll.dll
ModLoad: 00007ff9`25980000 00007ff9`25a3d000   C:\Windows\System32\KERNEL32.DLL
ModLoad: 00007ff9`246f0000 00007ff9`24a64000   C:\Windows\System32\KERNELBASE.dll
ModLoad: 00007ff9`250e0000 00007ff9`2518e000   C:\Windows\System32\ADVAPI32.dll
ModLoad: 00007ff9`25b20000 00007ff9`25bc3000   C:\Windows\System32\msvcrt.dll
ModLoad: 00007ff9`25a80000 00007ff9`25b1e000   C:\Windows\System32\sechost.dll
ModLoad: 00007ff9`25380000 00007ff9`254a0000   C:\Windows\System32\RPCRT4.dll
ModLoad: 00007ff9`261d0000 00007ff9`2697e000   C:\Windows\System32\SHELL32.dll
ModLoad: 00007ff9`24130000 00007ff9`241cd000   C:\Windows\System32\msvcp_win.dll
ModLoad: 00007ff9`24340000 00007ff9`24451000   C:\Windows\System32\ucrtbase.dll
ModLoad: 00007ff9`25660000 00007ff9`2580c000   C:\Windows\System32\USER32.dll
ModLoad: 00007ff9`24290000 00007ff9`242b6000   C:\Windows\System32\win32u.dll
ModLoad: 00007ff9`261a0000 00007ff9`261c9000   C:\Windows\System32\GDI32.dll
ModLoad: 00007ff9`24460000 00007ff9`24572000   C:\Windows\System32\gdi32full.dll
(1cc0.3588): Break instruction exception - code 80000003 (first chance)
ntdll!LdrpDoDebuggerBreak+0x30:
00007ff9`26d1cc74 cc              int     3
0:000> g
ModLoad: 00007ff9`25a40000 00007ff9`25a71000   C:\Windows\System32\IMM32.DLL
ntdll!NtTerminateProcess+0x14:
00007ff9`26ce3cd4 c3              ret
0:000> kb
 # RetAddr           : Args to Child                                                           : Call Site
00 00007ff9`26c94108 : 00000000`c0000005 00000000`001e3b50 00000000`001e3b48 00000000`00000000 : ntdll!NtTerminateProcess+0x14
01 00007ff9`2599c66b : 00000000`c0000005 00000000`001e3b50 00007ff9`25b99350 00000000`001e3b48 : ntdll!RtlExitUserProcess+0xb8
02 00007ff9`25b5d14d : 00000000`00000000 00000000`00000000 ffffffff`fffffffe 00007ff9`50000061 : KERNEL32!ExitProcessImplementation+0xb
03 00007ff9`25b5d7cb : 00000000`00000000 00000000`00000008 00000000`001e3b50 00000000`001e3b50 : msvcrt!_crtExitProcess+0x15
*** ERROR: Module load completed but symbols could not be loaded for C:\Program Files\R\R-4.1.2\bin\x64\R.exe
04 00000000`004064e3 : 00000000`00000000 00000000`00000029 00000000`00000000 00000000`00000000 : msvcrt!doexit+0x17b
05 00000000`004013c5 : 00000000`00000000 00000000`00000029 00000000`00000000 00000000`00000000 : R+0x64e3
06 00000000`0040152b : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : R+0x13c5
07 00007ff9`259954e0 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : R+0x152b
08 00007ff9`26c4485b : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : KERNEL32!BaseThreadInitThunk+0x10
09 00000000`00000000 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!RtlUserThreadStart+0x2b

Then I open Call stack.

 # Child-SP          RetAddr           Call Site
00 00000000`0062fcb8 00007ff9`26c94108 ntdll!NtTerminateProcess+0x14
01 00000000`0062fcc0 00007ff9`2599c66b ntdll!RtlExitUserProcess+0xb8
02 00000000`0062fcf0 00007ff9`25b5d14d KERNEL32!ExitProcessImplementation+0xb
03 00000000`0062fd20 00007ff9`25b5d7cb msvcrt!_crtExitProcess+0x15
04 00000000`0062fd50 00000000`004064e3 msvcrt!doexit+0x17b
05 00000000`0062fdc0 00000000`004013c5 R+0x64e3
06 00000000`0062fe30 00000000`0040152b R+0x13c5
07 00000000`0062ff00 00007ff9`259954e0 R+0x152b
08 00000000`0062ff30 00007ff9`26c4485b KERNEL32!BaseThreadInitThunk+0x10
09 00000000`0062ff60 00000000`00000000 ntdll!RtlUserThreadStart+0x2b

Is there any clue for you?

ZhangAngus commented 2 years ago

A series of further tests on other commands from package's examples . Error reproduced.

clear_registry()
# pass

font_fallback("\U0001f604")
# fail

font_feature(letters = "stylistic", numbers = c("lining", "tabular"))
# pass

font_info('serif')
# fail

match_font('sans', italic = TRUE)
# fail

# reset_font_cache()
# pass

string <- "This is a long string\nLook; It spans multiple lines\nand all"
shape_string(string)
# fail

string_metrics_dev(c('some text', 'a string with descenders'))
# pass

strings <- c('A short string', 'A very very looong string')
string_width(strings)
# fail

string_widths_dev(c('a string', 'an even longer string'))
# pass

emoji_string <- "This is a joke\U0001f642. It should be obvious from the smiley"
str_split_emoji(emoji_string)
# fail
ZhangAngus commented 2 years ago

Error fixed. Just uninstall system hotfix and all done.