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

Simon Urbanek simon.urbanek at r-project.org
Fri Jan 30 17:51:00 CET 2009


On Jan 30, 2009, at 10:30 , Christian Brechbühler wrote:

> On Thu, Jan 29, 2009 at 4:44 PM, Prof Brian Ripley <ripley at stats.ox.ac.uk 
> >wrote:
>
>> What did your actual application do?  This seems a very strange  
>> thing to
>> do, and the segfault is in trying to construct the traceback.
>>
>> Only by using do.call on the object (and not even by name) do I get  
>> this
>> error.  E.g.
>>
>> `[.data.frame`(1:10, 3)
>>>
>> Error in NextMethod("[") : object not specified
>>
>>> do.call("[.data.frame", list(1:10, 3))
>>>
>> Error in NextMethod("[") : object not specified
>>
>> are fine.
>>
>> Obviously it would be nice to fix this, but I'd like to understand  
>> the
>> actual circumstances: there is more to it than the subject line.
>
>
> Yes, there is more.  For reporting the problem, we tried to pare it  
> down to
> a concise, self-contained test case.
>
> My boss was debugging an issue in our R code.  We have our own "[...."
> functions, because stock R drops names when subscripting.

... if you tell it to do so, yes. If you tell it to not do that, it  
won't ... ever tried drop=FALSE ?

Cheers,
S


> To bypass our
> now-suspect functions and get the "real" subscripting method, he  
> used "get"
> from package:base.  He was examining a large object, and believing  
> it was a
> data frame, chose "[.data.frame".  As it turns out, that object was  
> not a
> data frame, and he got an unexpected segfault.  I think it was a  
> matrix.
> But it doesn't matter -- a vector as in the test case will give the  
> same.
>
> We have since fixed the bug in our replacement subscripting  
> function, so the
> issue might not affect us any more.
>
> Thanks,
> /Christian
>
>
>> On Thu, 29 Jan 2009, brechbuehler at gmail.com wrote:
>>
>> Full_Name: Christian Brechbuehler
>>> Version: 2.7.2, 2.8.1
>>> OS: linux-gnu
>>>
>>> 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.
>>>
>>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>



More information about the R-devel mailing list