[Rd] Segfault when mistakenly calling [.data.frame (PR#13487)

brechbuehler at gmail.com brechbuehler at gmail.com
Thu Jan 29 16:35:04 CET 2009


Full_Name: Christian Brechbuehler
Version: 2.7.2, 2.8.1
OS: linux-gnu
Submission from: (NULL) (24.128.51.18)


Calling [.data.frame on an object that's not a data frame, specifically 1:10,
causes segmentation fault.

Context
=======
We can subscript with a number of different notations:

   > (1:10)[3]
   [1] 3
   > do.call(get("[",pos="package:base"),list(1:10,3))
   [1] 3
   > do.call(get("[.numeric_version",pos="package:base"),list(1:10,3))
   [1] 3

Problem
=======
If we mistakenly believe the object is a data frame (as we did in a much more
complicated real situation), this happens: 

   > do.call(get("[.data.frame",pos="package:base"),list(1:10,3))
   Error in NextMethod("[") : 
     no calling generic was found: was a method called directly?

    *** caught segfault ***
   address (nil), cause 'unknown'

   Process R:2 segmentation fault (core dumped) at Thu Jan 29 09:26:29 2009

The Error message is appropriate.  But the segmentation fault is unexpected.


Versions
========
I reproduced the problem on R 2.7.2 and 2.8.1.  Details:

> version
               _                                          
platform       x86_64-unknown-linux-gnu                   
arch           x86_64                                     
os             linux-gnu                                  
system         x86_64, linux-gnu                          
status         Patched                                    
major          2                                          
minor          7.2                                        
year           2008                                       
month          09                                         
day            20                                         
svn rev        46776                                      
language       R                                          
version.string R version 2.7.2 Patched (2008-09-20 r46776)

==========================================================

> version
               _                                          
platform       x86_64-unknown-linux-gnu                   
arch           x86_64                                     
os             linux-gnu                                  
system         x86_64, linux-gnu                          
status         Patched                                    
major          2                                          
minor          8.1                                        
year           2009                                       
month          01                                         
day            26                                         
svn rev        47743                                      
language       R                                          
version.string R version 2.8.1 Patched (2009-01-26 r47743)



More information about the R-devel mailing list