Bug 16085 - stdwidth with SVG or Cairo devices crashes R
Summary: stdwidth with SVG or Cairo devices crashes R
Status: NEW
Alias: None
Product: R
Classification: Unclassified
Component: Graphics (show other bugs)
Version: R 3.1.2
Hardware: ix86 (32-bit) Windows 32-bit
: P5 major
Assignee: R-core
Depends on:
Reported: 2014-11-24 21:21 UTC by jpearson
Modified: 2015-09-09 08:50 UTC (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description jpearson 2014-11-24 21:21:46 UTC
#  Problem R 3.0.2 thru 3.1.2 abort and handles when the following sequence of 
#  commands are run.
#  It is documented that the strwidth command will return an error if the
#  units="user" and a plot.new() command has not been issued first. 
#  I've confirmed this.
#  However, this should not occur when units="inches" or "figure" 
#  is specified and a value should be returned.  
#  No plot.new() or plot(...) is required, per documentation. 
#  The tests were run on a windows XP 32-bit machine.  I have tried
#  R 3.0.2 up to 3.1.2 with the same results.
#  The strwidth code works perfectly when the output device 
#  is a "window", PDF, PNG, TIFF, JPEG or BMP.  strwidth returns
#  the strings width without a plot.new().    
#  It does not work on the cairo devices (pdf and ps) and "svg" devices.
#  It reports the error when the units="user", but when the units = 
#  "inches" or "figure", R crashes, windows reports the crash and attempts 
#  upload the dump, and R hangs. Clicking the STOP button or 
#  "menu" -> "stop current calculation" has no effect. 
#  The only way to stop/shutdown R is to "menu" -> "Stop All Computations"  
#  or kill R via the task manager.
#  The general test code pattern is the device setup/open statement followed
#  by the statements contain the strwidth function.
#  I've listed the device setup/open statements I used and one copy of the 
#  set of strwidth statements.


# The following setups work fine - 

png(file="test-png.png",width=7.5, height=10, units="in", res=300)

tiff(file="test-tiff.tif",width=7.5, height=10, units="in", res=300)

bmp(file="test-bmp.bmp",width=7.5, height=10, units="in")

jpeg(file="test-jpg.jpg",width=7.5, height=10, units="in", res=300)

postscript(file="test-ps.ps",width=7.5, height=10)

pdf(file="test-pdf.pdf",width=7.5, height=10)

# The following device setups crash RGui or R module and hang. 
#       (Typical crash vectors listed belows.)

cairo_ps(filename="test-cairo-ps.ps",width=7.5, height=10)

cairo_pdf(filename="test-cairo-pdf.pdf", width=7.5, height=10)


## code following each device setup call.

ID.width <- strwidth("Just a String")    # returns error message since units="usr"

ID.width <- strwidth("Just a String",units="figure")

ID.width <- strwidth("Just a String",units="inches")


#   A workaround is to make sure a plot.new() is executed before the 
#   strwidth function is executed, regardless of the type of units requested.
#   I'm working to see if this will work in my package without creating 
#   problems.

The debug information provided by windows is:

unhandled exception at 0x6990de4b in Rgui.exe: 0xc00000005: Access violation reading location 0x000000004.

6990DE23  mov         dword ptr [esp],1 
6990DE2A  call        6990BEC4 
6990DE2F  mov         eax,699E2178h 
6990DE34  jmp         6990DE1D 
6990DE36  xchg        ax,ax 
6990DE38  push        ebp  
6990DE39  mov         ebp,esp 
6990DE3B  push        ebx  
6990DE3C  sub         esp,14h 
6990DE3F  mov         ebx,dword ptr [ebp+8] 
6990DE42  mov         eax,dword ptr [ebp+0Ch] 
6990DE45  mov         edx,dword ptr [ebp+10h] 
6990DE48  mov         ecx,dword ptr [ebp+14h] 
6990DE4B  cmp         dword ptr [ebx+4],0              <----- abort
6990DE4F  je          6990DE58 
6990DE51  add         esp,14h 
6990DE54  pop         ebx  
6990DE55  leave            
6990DE56  ret              
6990DE57  nop              
6990DE58  mov         dword ptr [esp+0Ch],ecx 
6990DE5C  mov         dword ptr [esp+8],edx 
6990DE60  mov         dword ptr [esp+4],eax 
6990DE64  mov         eax,dword ptr [ebx+1Ch] 
6990DE67  mov         dword ptr [esp],eax 
6990DE6A  call        699484D8 
6990DE6F  test        eax,eax 
6990DE71  je          6990DE51 
6990DE73  mov         edx,eax 
6990DE75  mov         eax,ebx 
6990DE77  add         esp,14h 
6990DE7A  pop         ebx

EBX	=	00000000
EAX	=	699DA128
EBP 	=	014DD868
EDX 	=	00000000
ECX	=	00000000

Sincerely, Jim.