Bug 15883 - Setting options(device) to a non-device function segfaults
Summary: Setting options(device) to a non-device function segfaults
Status: NEW
Alias: None
Product: R
Classification: Unclassified
Component: Graphics (show other bugs)
Version: R 3.1.0
Hardware: Other Linux
: P5 normal
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2014-07-15 15:13 UTC by Barry Rowlingson
Modified: 2014-07-15 15:13 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Barry Rowlingson 2014-07-15 15:13:04 UTC
Setting options(device) to something dumb then plotting causes a segfault:

> options(device=function(...){});plot(1)

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

Traceback:
 1: dev.hold()
 2: plot.default(1)
 3: plot(1)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit

Yes, doing a dumb thing is dumb but if someone is developing new graphics devices then it might be nice if it was robust to things like this. I suspect the graphics system doesn't know that options(device) hasn't created a graphics device structure and blunders on regardless, smashing memory in the process.

Also happens on Windows and Mac.

> sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_GB.utf8       LC_NUMERIC=C             
 [3] LC_TIME=en_GB.utf8        LC_COLLATE=en_GB.utf8    
 [5] LC_MONETARY=en_GB.utf8    LC_MESSAGES=en_GB.utf8   
 [7] LC_PAPER=en_GB.utf8       LC_NAME=C                
 [9] LC_ADDRESS=C              LC_TELEPHONE=C           
[11] LC_MEASUREMENT=en_GB.utf8 LC_IDENTIFICATION=C      

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