[R-pkg-devel] R session crash on closing a graphic device on Windows

Hiroaki Yutani yut@n|@|n| @end|ng |rom gm@||@com
Sat Jan 22 10:50:09 CET 2022


Hi,

I'm trying to create a Rust library that can implement an R graphic
device[1], but the R session crashes on `dev.off()` on Windows with R
4.1.2. Strangely, it works without errors on Linux, on macOS, and even
on Windows with R-devel.

Looking at the stack trace below by WinDbg, the problem is probably
that either of the two free()s in GEdestroyDevDesc() tries to free
some memory that was already freed (I'm a very beginner of this kind
of debugging, so I might be wrong).

    # Child-SP          RetAddr               Call Site
    00 00000000`0441cb70 00007ffb`3df0be63     ntdll!RtlReportFatalFailure+0x9
    01 00000000`0441cbc0 00007ffb`3df14c82
ntdll!RtlReportCriticalFailure+0x97
    ...snip...
    08 00000000`0441cfc0 00007ffb`3c30c6ac     ntdll!RtlFreeHeap+0x51
    09 00000000`0441d000 00000000`6c7bcf99     msvcrt!free+0x1c
    0a 00000000`0441d030 00000000`6c79e7de     R!GEdestroyDevDesc+0x59
    0b 00000000`0441d080 00000000`6fc828e9     R!GEcurrentDevice+0x37e
    0c 00000000`0441d0f0 00000000`6c7a15fa     grDevices!devoff+0x59
    ...snip...

But, I found no difference in the related code (around devoff() and
GEdestroyDevDesc()) between R 4.1.2 and R-devel. I know there are a
lot of feature additions in R-devel, but I don't think it affects
here. Is there anyone who suffered from similar crashes? Am I missing
something?

I would appreciate any advice.

Best,
Yutani

[1]: https://github.com/extendr/extendr/pull/360



More information about the R-package-devel mailing list