Re: [Bioc-devel] The story of tracing a derfinder bug on OSX that sometimes popped up, sometimes it didn't. Related to IRanges/S4Vectors '$<-'

2017-03-30 Thread Michael Lawrence
Yea I will have to port the recent fixes.

On Wed, Mar 29, 2017 at 11:32 PM, Hervé Pagès  wrote:
> On 03/27/2017 09:43 AM, Michael Lawrence wrote:
>>
>> I committed a fix into R trunk with a regression test.
>
>
> Thanks Michael. Any chance you can port the fix to the 3.4 branch?
>
> H.
>
>>
>> On Mon, Mar 27, 2017 at 8:41 AM, Michael Lawrence 
>> wrote:
>>>
>>> My bad guys, I'll fix when I get to work.
>>>
>>> On Mon, Mar 27, 2017 at 3:59 AM, Martin Morgan
>>>  wrote:

 On 03/22/2017 01:12 PM, Hervé Pagès wrote:
>
>
> Hi Martin,
>
> On 03/22/2017 03:17 AM, Martin Maechler wrote:
>>>
>>>
>>> Andrzej Oleś 
>>> on Wed, 22 Mar 2017 10:29:57 +0100 writes:
>>
>>
>>
>> > Just for the record, on R-3.3.2 Herve's code fails with the
>> following error:
>> > Error in x[TRUE] <- new("A") :
>> > incompatible types (from S4 to logical) in subassignment type
>> fix
>>
>> yes, (of course) and I would be interested in a small
>> reproducible example which uses _valid_ code.
>
>
>
> Looks like before performing the subassignment itself, [<- first tries
> to coerce the RHS to the "mode" of the LHS by calling as.vector() on
> the
> former. So if we define an as.vector S3 method for A objects:
>
>   setClass("A", representation(stuff="numeric"))
>   as.vector.A <- function (x, mode="any") x@stuff
>   a <- new("A", stuff=c(3.5, 0.1))
>   x <- numeric(10)
>   x[3:4] <- a



 The relevant stack trace is

   * frame #0: 0x00010dded77a
 libR.dylib`R_has_methods(op=)
 + 74 at objects.c:1415
 frame #1: 0x00010ddaabf4
 libR.dylib`Rf_DispatchOrEval(call=0x7fcea36f68a8,
 op=0x7fcea201a178,
 generic=0x00010df0a185, args=, rho=0x7fcea2053318,
 ans=0x7fff51f60c48, dropmissing=, argsevald=1) + 404 at
 eval.c:3150
 frame #2: 0x00010de4e658 libR.dylib`SubassignTypeFix [inlined]
 dispatch_asvector(x=, call=0x7fcea36f68a8,
 rho=0x7fcea2053318) + 295 at subassign.c:283


 The segfault is at objects.c:1415

 offset = PRIMOFFSET(op);
 if(offset > curMaxOffset || prim_methods[offset] == NO_METHODS
|| prim_methods[offset] == SUPPRESSED)

 where offset is negative and prim_methods[offset] fails.

 (lldb) p *op
 (SEXPREC) $8 = {
   sxpinfo = (type = 0, obj = 0, named = 2, gp = 0, mark = 1, debug = 0,
 trace = 0, spare = 0, gcgen = 1, gccls = 0)
   attrib = 0x7fcea201a178
   gengc_next_node = 0x7fcea21874e8
   gengc_prev_node = 0x7fcea2019ff0
   u = {
 primsxp = (offset = -1576951432)
 symsxp = {


 'op' is assigned from subassign.c:287, op = R_Primitive("as.vector")

 static Rboolean dispatch_asvector(SEXP *x, SEXP call, SEXP rho) {
 static SEXP op = NULL;
 SEXP args;
 Rboolean ans;
 if (op == NULL)
 op = R_Primitive("as.vector");
 PROTECT(args = list2(*x, mkString("any")));
 ans = DispatchOrEval(call, op, "as.vector", args, rho, x, 0, 1);
 UNPROTECT(1);
 return ans;
 }

 But as.vector is not a primitive, so gets R_NilValue. This is passed to
 DispatchOrEval, and then to R_has_methods.

 It seems like dispatch_asvector() was introduced by

 $ svn log -c69747
 
 r69747 | lawrence | 2015-12-09 09:04:56 -0500 (Wed, 09 Dec 2015) | 3
 lines

 subassignment of an S4 value into an atomic vector coerces the value
 with as.vector

 

 So maybe Michael can tell us about his thinking here.

 Also, should R_has_methods be robust to R_NilValue? And R_NilValue
 explicitly zero it's data?

 Martin



>
> then the code is now valid and we still get the segfault on Mac.
>
> I didn't define as.vector.A in my original minimalist reproducible
> code in order to keep it as simple as possible.
>
> H.
>
>
>> We have seen such examples with something (more complicated
>> than, but basically like)
>>
>>   df <- data.frame(x=1:5, y=5:1, m=matrix(-pi*1:30, 5,6))
>>   M <- Matrix::Matrix(exp(0:3),2)
>>   df[1:2,1:2] <- M
>>
>> which actually calls `[<-`, and then `[<-.data.frame`  and
>> always works for me but does seg.fault (in the CRAN checks of
>> package FastImputation (on 3 of the dozen platforms,
>>
>>
>> 

Re: [Bioc-devel] The story of tracing a derfinder bug on OSX that sometimes popped up, sometimes it didn't. Related to IRanges/S4Vectors '$<-'

2017-03-30 Thread Hervé Pagès

On 03/27/2017 09:43 AM, Michael Lawrence wrote:

I committed a fix into R trunk with a regression test.


Thanks Michael. Any chance you can port the fix to the 3.4 branch?

H.



On Mon, Mar 27, 2017 at 8:41 AM, Michael Lawrence  wrote:

My bad guys, I'll fix when I get to work.

On Mon, Mar 27, 2017 at 3:59 AM, Martin Morgan
 wrote:

On 03/22/2017 01:12 PM, Hervé Pagès wrote:


Hi Martin,

On 03/22/2017 03:17 AM, Martin Maechler wrote:


Andrzej Oleś 
on Wed, 22 Mar 2017 10:29:57 +0100 writes:



> Just for the record, on R-3.3.2 Herve's code fails with the
following error:
> Error in x[TRUE] <- new("A") :
> incompatible types (from S4 to logical) in subassignment type fix

yes, (of course) and I would be interested in a small
reproducible example which uses _valid_ code.



Looks like before performing the subassignment itself, [<- first tries
to coerce the RHS to the "mode" of the LHS by calling as.vector() on the
former. So if we define an as.vector S3 method for A objects:

  setClass("A", representation(stuff="numeric"))
  as.vector.A <- function (x, mode="any") x@stuff
  a <- new("A", stuff=c(3.5, 0.1))
  x <- numeric(10)
  x[3:4] <- a



The relevant stack trace is

  * frame #0: 0x00010dded77a libR.dylib`R_has_methods(op=)
+ 74 at objects.c:1415
frame #1: 0x00010ddaabf4
libR.dylib`Rf_DispatchOrEval(call=0x7fcea36f68a8, op=0x7fcea201a178,
generic=0x00010df0a185, args=, rho=0x7fcea2053318,
ans=0x7fff51f60c48, dropmissing=, argsevald=1) + 404 at
eval.c:3150
frame #2: 0x00010de4e658 libR.dylib`SubassignTypeFix [inlined]
dispatch_asvector(x=, call=0x7fcea36f68a8,
rho=0x7fcea2053318) + 295 at subassign.c:283


The segfault is at objects.c:1415

offset = PRIMOFFSET(op);
if(offset > curMaxOffset || prim_methods[offset] == NO_METHODS
   || prim_methods[offset] == SUPPRESSED)

where offset is negative and prim_methods[offset] fails.

(lldb) p *op
(SEXPREC) $8 = {
  sxpinfo = (type = 0, obj = 0, named = 2, gp = 0, mark = 1, debug = 0,
trace = 0, spare = 0, gcgen = 1, gccls = 0)
  attrib = 0x7fcea201a178
  gengc_next_node = 0x7fcea21874e8
  gengc_prev_node = 0x7fcea2019ff0
  u = {
primsxp = (offset = -1576951432)
symsxp = {


'op' is assigned from subassign.c:287, op = R_Primitive("as.vector")

static Rboolean dispatch_asvector(SEXP *x, SEXP call, SEXP rho) {
static SEXP op = NULL;
SEXP args;
Rboolean ans;
if (op == NULL)
op = R_Primitive("as.vector");
PROTECT(args = list2(*x, mkString("any")));
ans = DispatchOrEval(call, op, "as.vector", args, rho, x, 0, 1);
UNPROTECT(1);
return ans;
}

But as.vector is not a primitive, so gets R_NilValue. This is passed to
DispatchOrEval, and then to R_has_methods.

It seems like dispatch_asvector() was introduced by

$ svn log -c69747

r69747 | lawrence | 2015-12-09 09:04:56 -0500 (Wed, 09 Dec 2015) | 3 lines

subassignment of an S4 value into an atomic vector coerces the value
with as.vector



So maybe Michael can tell us about his thinking here.

Also, should R_has_methods be robust to R_NilValue? And R_NilValue
explicitly zero it's data?

Martin





then the code is now valid and we still get the segfault on Mac.

I didn't define as.vector.A in my original minimalist reproducible
code in order to keep it as simple as possible.

H.



We have seen such examples with something (more complicated
than, but basically like)

  df <- data.frame(x=1:5, y=5:1, m=matrix(-pi*1:30, 5,6))
  M <- Matrix::Matrix(exp(0:3),2)
  df[1:2,1:2] <- M

which actually calls `[<-`, and then `[<-.data.frame`  and
always works for me but does seg.fault (in the CRAN checks of
package FastImputation (on 3 of the dozen platforms,

https://urldefense.proofpoint.com/v2/url?u=https-3A__cran.r-2Dproject.org_web_checks_check-5Fresults-5FFastImputation.html=DwIGaQ=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=ILfV0tHrE_BxAkWYlvUUwWcBdBdtVD7BlEljGiO3WbY=zUahQYlBHRwNf6lPnSA1515Rm-iL5ffQI7hUcDW-JkE=


one of them is


https://urldefense.proofpoint.com/v2/url?u=https-3A__www.r-2Dproject.org_nosvn_R.check_r-2Ddevel-2Dmacos-2Dx86-5F64-2Dclang_FastImputation-2D00check.html=DwIGaQ=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=ILfV0tHrE_BxAkWYlvUUwWcBdBdtVD7BlEljGiO3WbY=Z7LkVlUzmdmhqxGNFl4LuMVxYwQQGHSV7KdpKCJu12k=


I strongly suspect this is the same bug as yours, but for a case
where the correct behavior is *not* giving an error.

I have also written and shown  Herve's example  to the R-core team.

Unfortunately, I have no platform where I can trigger the bug.
Martin



> Cheers,
> Andrzej



> On Wed, Mar 22, 2017 at 1:28 AM, Martin Morgan <
> martin.mor...@roswellpark.org> wrote:

>> On 

Re: [Bioc-devel] The story of tracing a derfinder bug on OSX that sometimes popped up, sometimes it didn't. Related to IRanges/S4Vectors '$<-'

2017-03-27 Thread Michael Lawrence
I committed a fix into R trunk with a regression test.

On Mon, Mar 27, 2017 at 8:41 AM, Michael Lawrence  wrote:
> My bad guys, I'll fix when I get to work.
>
> On Mon, Mar 27, 2017 at 3:59 AM, Martin Morgan
>  wrote:
>> On 03/22/2017 01:12 PM, Hervé Pagès wrote:
>>>
>>> Hi Martin,
>>>
>>> On 03/22/2017 03:17 AM, Martin Maechler wrote:
>
> Andrzej Oleś 
> on Wed, 22 Mar 2017 10:29:57 +0100 writes:


 > Just for the record, on R-3.3.2 Herve's code fails with the
 following error:
 > Error in x[TRUE] <- new("A") :
 > incompatible types (from S4 to logical) in subassignment type fix

 yes, (of course) and I would be interested in a small
 reproducible example which uses _valid_ code.
>>>
>>>
>>> Looks like before performing the subassignment itself, [<- first tries
>>> to coerce the RHS to the "mode" of the LHS by calling as.vector() on the
>>> former. So if we define an as.vector S3 method for A objects:
>>>
>>>   setClass("A", representation(stuff="numeric"))
>>>   as.vector.A <- function (x, mode="any") x@stuff
>>>   a <- new("A", stuff=c(3.5, 0.1))
>>>   x <- numeric(10)
>>>   x[3:4] <- a
>>
>>
>> The relevant stack trace is
>>
>>   * frame #0: 0x00010dded77a libR.dylib`R_has_methods(op=)
>> + 74 at objects.c:1415
>> frame #1: 0x00010ddaabf4
>> libR.dylib`Rf_DispatchOrEval(call=0x7fcea36f68a8, op=0x7fcea201a178,
>> generic=0x00010df0a185, args=, rho=0x7fcea2053318,
>> ans=0x7fff51f60c48, dropmissing=, argsevald=1) + 404 at
>> eval.c:3150
>> frame #2: 0x00010de4e658 libR.dylib`SubassignTypeFix [inlined]
>> dispatch_asvector(x=, call=0x7fcea36f68a8,
>> rho=0x7fcea2053318) + 295 at subassign.c:283
>>
>>
>> The segfault is at objects.c:1415
>>
>> offset = PRIMOFFSET(op);
>> if(offset > curMaxOffset || prim_methods[offset] == NO_METHODS
>>|| prim_methods[offset] == SUPPRESSED)
>>
>> where offset is negative and prim_methods[offset] fails.
>>
>> (lldb) p *op
>> (SEXPREC) $8 = {
>>   sxpinfo = (type = 0, obj = 0, named = 2, gp = 0, mark = 1, debug = 0,
>> trace = 0, spare = 0, gcgen = 1, gccls = 0)
>>   attrib = 0x7fcea201a178
>>   gengc_next_node = 0x7fcea21874e8
>>   gengc_prev_node = 0x7fcea2019ff0
>>   u = {
>> primsxp = (offset = -1576951432)
>> symsxp = {
>>
>>
>> 'op' is assigned from subassign.c:287, op = R_Primitive("as.vector")
>>
>> static Rboolean dispatch_asvector(SEXP *x, SEXP call, SEXP rho) {
>> static SEXP op = NULL;
>> SEXP args;
>> Rboolean ans;
>> if (op == NULL)
>> op = R_Primitive("as.vector");
>> PROTECT(args = list2(*x, mkString("any")));
>> ans = DispatchOrEval(call, op, "as.vector", args, rho, x, 0, 1);
>> UNPROTECT(1);
>> return ans;
>> }
>>
>> But as.vector is not a primitive, so gets R_NilValue. This is passed to
>> DispatchOrEval, and then to R_has_methods.
>>
>> It seems like dispatch_asvector() was introduced by
>>
>> $ svn log -c69747
>> 
>> r69747 | lawrence | 2015-12-09 09:04:56 -0500 (Wed, 09 Dec 2015) | 3 lines
>>
>> subassignment of an S4 value into an atomic vector coerces the value
>> with as.vector
>>
>> 
>>
>> So maybe Michael can tell us about his thinking here.
>>
>> Also, should R_has_methods be robust to R_NilValue? And R_NilValue
>> explicitly zero it's data?
>>
>> Martin
>>
>>
>>
>>>
>>> then the code is now valid and we still get the segfault on Mac.
>>>
>>> I didn't define as.vector.A in my original minimalist reproducible
>>> code in order to keep it as simple as possible.
>>>
>>> H.
>>>
>>>
 We have seen such examples with something (more complicated
 than, but basically like)

   df <- data.frame(x=1:5, y=5:1, m=matrix(-pi*1:30, 5,6))
   M <- Matrix::Matrix(exp(0:3),2)
   df[1:2,1:2] <- M

 which actually calls `[<-`, and then `[<-.data.frame`  and
 always works for me but does seg.fault (in the CRAN checks of
 package FastImputation (on 3 of the dozen platforms,

 https://urldefense.proofpoint.com/v2/url?u=https-3A__cran.r-2Dproject.org_web_checks_check-5Fresults-5FFastImputation.html=DwIGaQ=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=ILfV0tHrE_BxAkWYlvUUwWcBdBdtVD7BlEljGiO3WbY=zUahQYlBHRwNf6lPnSA1515Rm-iL5ffQI7hUcDW-JkE=


 one of them is


 https://urldefense.proofpoint.com/v2/url?u=https-3A__www.r-2Dproject.org_nosvn_R.check_r-2Ddevel-2Dmacos-2Dx86-5F64-2Dclang_FastImputation-2D00check.html=DwIGaQ=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=ILfV0tHrE_BxAkWYlvUUwWcBdBdtVD7BlEljGiO3WbY=Z7LkVlUzmdmhqxGNFl4LuMVxYwQQGHSV7KdpKCJu12k=


 I strongly suspect this is the same bug as yours, but for a case
 where the 

Re: [Bioc-devel] The story of tracing a derfinder bug on OSX that sometimes popped up, sometimes it didn't. Related to IRanges/S4Vectors '$<-'

2017-03-27 Thread Michael Lawrence
My bad guys, I'll fix when I get to work.

On Mon, Mar 27, 2017 at 3:59 AM, Martin Morgan
 wrote:
> On 03/22/2017 01:12 PM, Hervé Pagès wrote:
>>
>> Hi Martin,
>>
>> On 03/22/2017 03:17 AM, Martin Maechler wrote:

 Andrzej Oleś 
 on Wed, 22 Mar 2017 10:29:57 +0100 writes:
>>>
>>>
>>> > Just for the record, on R-3.3.2 Herve's code fails with the
>>> following error:
>>> > Error in x[TRUE] <- new("A") :
>>> > incompatible types (from S4 to logical) in subassignment type fix
>>>
>>> yes, (of course) and I would be interested in a small
>>> reproducible example which uses _valid_ code.
>>
>>
>> Looks like before performing the subassignment itself, [<- first tries
>> to coerce the RHS to the "mode" of the LHS by calling as.vector() on the
>> former. So if we define an as.vector S3 method for A objects:
>>
>>   setClass("A", representation(stuff="numeric"))
>>   as.vector.A <- function (x, mode="any") x@stuff
>>   a <- new("A", stuff=c(3.5, 0.1))
>>   x <- numeric(10)
>>   x[3:4] <- a
>
>
> The relevant stack trace is
>
>   * frame #0: 0x00010dded77a libR.dylib`R_has_methods(op=)
> + 74 at objects.c:1415
> frame #1: 0x00010ddaabf4
> libR.dylib`Rf_DispatchOrEval(call=0x7fcea36f68a8, op=0x7fcea201a178,
> generic=0x00010df0a185, args=, rho=0x7fcea2053318,
> ans=0x7fff51f60c48, dropmissing=, argsevald=1) + 404 at
> eval.c:3150
> frame #2: 0x00010de4e658 libR.dylib`SubassignTypeFix [inlined]
> dispatch_asvector(x=, call=0x7fcea36f68a8,
> rho=0x7fcea2053318) + 295 at subassign.c:283
>
>
> The segfault is at objects.c:1415
>
> offset = PRIMOFFSET(op);
> if(offset > curMaxOffset || prim_methods[offset] == NO_METHODS
>|| prim_methods[offset] == SUPPRESSED)
>
> where offset is negative and prim_methods[offset] fails.
>
> (lldb) p *op
> (SEXPREC) $8 = {
>   sxpinfo = (type = 0, obj = 0, named = 2, gp = 0, mark = 1, debug = 0,
> trace = 0, spare = 0, gcgen = 1, gccls = 0)
>   attrib = 0x7fcea201a178
>   gengc_next_node = 0x7fcea21874e8
>   gengc_prev_node = 0x7fcea2019ff0
>   u = {
> primsxp = (offset = -1576951432)
> symsxp = {
>
>
> 'op' is assigned from subassign.c:287, op = R_Primitive("as.vector")
>
> static Rboolean dispatch_asvector(SEXP *x, SEXP call, SEXP rho) {
> static SEXP op = NULL;
> SEXP args;
> Rboolean ans;
> if (op == NULL)
> op = R_Primitive("as.vector");
> PROTECT(args = list2(*x, mkString("any")));
> ans = DispatchOrEval(call, op, "as.vector", args, rho, x, 0, 1);
> UNPROTECT(1);
> return ans;
> }
>
> But as.vector is not a primitive, so gets R_NilValue. This is passed to
> DispatchOrEval, and then to R_has_methods.
>
> It seems like dispatch_asvector() was introduced by
>
> $ svn log -c69747
> 
> r69747 | lawrence | 2015-12-09 09:04:56 -0500 (Wed, 09 Dec 2015) | 3 lines
>
> subassignment of an S4 value into an atomic vector coerces the value
> with as.vector
>
> 
>
> So maybe Michael can tell us about his thinking here.
>
> Also, should R_has_methods be robust to R_NilValue? And R_NilValue
> explicitly zero it's data?
>
> Martin
>
>
>
>>
>> then the code is now valid and we still get the segfault on Mac.
>>
>> I didn't define as.vector.A in my original minimalist reproducible
>> code in order to keep it as simple as possible.
>>
>> H.
>>
>>
>>> We have seen such examples with something (more complicated
>>> than, but basically like)
>>>
>>>   df <- data.frame(x=1:5, y=5:1, m=matrix(-pi*1:30, 5,6))
>>>   M <- Matrix::Matrix(exp(0:3),2)
>>>   df[1:2,1:2] <- M
>>>
>>> which actually calls `[<-`, and then `[<-.data.frame`  and
>>> always works for me but does seg.fault (in the CRAN checks of
>>> package FastImputation (on 3 of the dozen platforms,
>>>
>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__cran.r-2Dproject.org_web_checks_check-5Fresults-5FFastImputation.html=DwIGaQ=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=ILfV0tHrE_BxAkWYlvUUwWcBdBdtVD7BlEljGiO3WbY=zUahQYlBHRwNf6lPnSA1515Rm-iL5ffQI7hUcDW-JkE=
>>>
>>>
>>> one of them is
>>>
>>>
>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.r-2Dproject.org_nosvn_R.check_r-2Ddevel-2Dmacos-2Dx86-5F64-2Dclang_FastImputation-2D00check.html=DwIGaQ=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=ILfV0tHrE_BxAkWYlvUUwWcBdBdtVD7BlEljGiO3WbY=Z7LkVlUzmdmhqxGNFl4LuMVxYwQQGHSV7KdpKCJu12k=
>>>
>>>
>>> I strongly suspect this is the same bug as yours, but for a case
>>> where the correct behavior is *not* giving an error.
>>>
>>> I have also written and shown  Herve's example  to the R-core team.
>>>
>>> Unfortunately, I have no platform where I can trigger the bug.
>>> Martin
>>>
>>>
>>>
>>> > Cheers,
>>> > Andrzej
>>>
>>>
>>>
>>> > On 

Re: [Bioc-devel] The story of tracing a derfinder bug on OSX that sometimes popped up, sometimes it didn't. Related to IRanges/S4Vectors '$<-'

2017-03-27 Thread Martin Morgan

On 03/22/2017 01:12 PM, Hervé Pagès wrote:

Hi Martin,

On 03/22/2017 03:17 AM, Martin Maechler wrote:

Andrzej Oleś 
on Wed, 22 Mar 2017 10:29:57 +0100 writes:


> Just for the record, on R-3.3.2 Herve's code fails with the
following error:
> Error in x[TRUE] <- new("A") :
> incompatible types (from S4 to logical) in subassignment type fix

yes, (of course) and I would be interested in a small
reproducible example which uses _valid_ code.


Looks like before performing the subassignment itself, [<- first tries
to coerce the RHS to the "mode" of the LHS by calling as.vector() on the
former. So if we define an as.vector S3 method for A objects:

  setClass("A", representation(stuff="numeric"))
  as.vector.A <- function (x, mode="any") x@stuff
  a <- new("A", stuff=c(3.5, 0.1))
  x <- numeric(10)
  x[3:4] <- a


The relevant stack trace is

  * frame #0: 0x00010dded77a 
libR.dylib`R_has_methods(op=) + 74 at objects.c:1415
frame #1: 0x00010ddaabf4 
libR.dylib`Rf_DispatchOrEval(call=0x7fcea36f68a8, 
op=0x7fcea201a178, generic=0x00010df0a185, args=, 
rho=0x7fcea2053318, ans=0x7fff51f60c48, 
dropmissing=, argsevald=1) + 404 at eval.c:3150
frame #2: 0x00010de4e658 libR.dylib`SubassignTypeFix [inlined] 
dispatch_asvector(x=, call=0x7fcea36f68a8, 
rho=0x7fcea2053318) + 295 at subassign.c:283



The segfault is at objects.c:1415

offset = PRIMOFFSET(op);
if(offset > curMaxOffset || prim_methods[offset] == NO_METHODS
   || prim_methods[offset] == SUPPRESSED)

where offset is negative and prim_methods[offset] fails.

(lldb) p *op
(SEXPREC) $8 = {
  sxpinfo = (type = 0, obj = 0, named = 2, gp = 0, mark = 1, debug = 0, 
trace = 0, spare = 0, gcgen = 1, gccls = 0)

  attrib = 0x7fcea201a178
  gengc_next_node = 0x7fcea21874e8
  gengc_prev_node = 0x7fcea2019ff0
  u = {
primsxp = (offset = -1576951432)
symsxp = {


'op' is assigned from subassign.c:287, op = R_Primitive("as.vector")

static Rboolean dispatch_asvector(SEXP *x, SEXP call, SEXP rho) {
static SEXP op = NULL;
SEXP args;
Rboolean ans;
if (op == NULL)
op = R_Primitive("as.vector");
PROTECT(args = list2(*x, mkString("any")));
ans = DispatchOrEval(call, op, "as.vector", args, rho, x, 0, 1);
UNPROTECT(1);
return ans;
}

But as.vector is not a primitive, so gets R_NilValue. This is passed to 
DispatchOrEval, and then to R_has_methods.


It seems like dispatch_asvector() was introduced by

$ svn log -c69747

r69747 | lawrence | 2015-12-09 09:04:56 -0500 (Wed, 09 Dec 2015) | 3 lines

subassignment of an S4 value into an atomic vector coerces the value
with as.vector



So maybe Michael can tell us about his thinking here.

Also, should R_has_methods be robust to R_NilValue? And R_NilValue 
explicitly zero it's data?


Martin




then the code is now valid and we still get the segfault on Mac.

I didn't define as.vector.A in my original minimalist reproducible
code in order to keep it as simple as possible.

H.



We have seen such examples with something (more complicated
than, but basically like)

  df <- data.frame(x=1:5, y=5:1, m=matrix(-pi*1:30, 5,6))
  M <- Matrix::Matrix(exp(0:3),2)
  df[1:2,1:2] <- M

which actually calls `[<-`, and then `[<-.data.frame`  and
always works for me but does seg.fault (in the CRAN checks of
package FastImputation (on 3 of the dozen platforms,
https://urldefense.proofpoint.com/v2/url?u=https-3A__cran.r-2Dproject.org_web_checks_check-5Fresults-5FFastImputation.html=DwIGaQ=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=ILfV0tHrE_BxAkWYlvUUwWcBdBdtVD7BlEljGiO3WbY=zUahQYlBHRwNf6lPnSA1515Rm-iL5ffQI7hUcDW-JkE=


one of them is

 
https://urldefense.proofpoint.com/v2/url?u=https-3A__www.r-2Dproject.org_nosvn_R.check_r-2Ddevel-2Dmacos-2Dx86-5F64-2Dclang_FastImputation-2D00check.html=DwIGaQ=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=ILfV0tHrE_BxAkWYlvUUwWcBdBdtVD7BlEljGiO3WbY=Z7LkVlUzmdmhqxGNFl4LuMVxYwQQGHSV7KdpKCJu12k=


I strongly suspect this is the same bug as yours, but for a case
where the correct behavior is *not* giving an error.

I have also written and shown  Herve's example  to the R-core team.

Unfortunately, I have no platform where I can trigger the bug.
Martin



> Cheers,
> Andrzej



> On Wed, Mar 22, 2017 at 1:28 AM, Martin Morgan <
> martin.mor...@roswellpark.org> wrote:

>> On 03/21/2017 08:21 PM, Hervé Pagès wrote:
>>
>>> Hi Leonardo,
>>>
>>> Thanks for hunting down and isolating that bug! I tried to
simplify
>>> your code even more and was able to get a segfault with just:
>>>
>>> setClass("A", representation(stuff="numeric"))
>>> x <- logical(10)
>>> x[TRUE] <- new("A")
>>>
>>> I get the segfault about 50% of 

Re: [Bioc-devel] The story of tracing a derfinder bug on OSX that sometimes popped up, sometimes it didn't. Related to IRanges/S4Vectors '$<-'

2017-03-22 Thread Andrzej Oleś
On Wed, Mar 22, 2017 at 6:12 PM, Hervé Pagès  wrote:

>
>   setClass("A", representation(stuff="numeric"))
>   as.vector.A <- function (x, mode="any") x@stuff
>   a <- new("A", stuff=c(3.5, 0.1))
>   x <- numeric(10)
>   x[3:4] <- a
>
> then the code is now valid and we still get the segfault on Mac.
>

Thanks Hervé for the updated MWE.  As suggested by Martin and Dan I've run
it through valgrind on Linux but it didn't give any errors...

Andrzej

[[alternative HTML version deleted]]

___
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel

Re: [Bioc-devel] The story of tracing a derfinder bug on OSX that sometimes popped up, sometimes it didn't. Related to IRanges/S4Vectors '$<-'

2017-03-22 Thread Dan Tenenbaum


- Original Message -
> From: "Hervé Pagès" 
> To: "Martin Morgan" , "lcollado" 
> , "bioc-devel"
> 
> Cc: "Jeff Leek" , "Andrew Jaffe" 
> Sent: Wednesday, March 22, 2017 10:21:43 AM
> Subject: Re: [Bioc-devel] The story of tracing a derfinder bug on OSX that 
> sometimes popped up, sometimes it didn't.
> Related to IRanges/S4Vectors '$<-'

> On 03/21/2017 05:28 PM, Martin Morgan wrote:
>> On 03/21/2017 08:21 PM, Hervé Pagès wrote:
>>> Hi Leonardo,
>>>
>>> Thanks for hunting down and isolating that bug! I tried to simplify
>>> your code even more and was able to get a segfault with just:
>>>
>>>   setClass("A", representation(stuff="numeric"))
>>>   x <- logical(10)
>>>   x[TRUE] <- new("A")
>>>
>>> I get the segfault about 50% of the time on a fresh R session on Mac.
>>> I tried this with R 3.3.3 on Mavericks, and with R devel (r72372)
>>> on El Capitan. I get the segfault on both.
>>>
>>> So it looks like a bug in the `[<-` primitive to me (subassignment).
>>
>> Any insight from
>>
>>   R -d valgrind -f herve.R
>>
>> where herve.R contains the code above?
> 
> That's a little bit complicated for me at the moment. I was
> actually running this code on build machines toluca2 and (upcoming)
> veracruz2 and we don't have valgrind there for now. I don't have
> access to other Macs so hopefully someone else will be able to help
> with this.
> 

Just running valgrind on linux should reveal something
Dan


> H.
> 
>>
>> Martin
>>
>>>
>>> Cheers,
>>> H.
>>>
>>> On 03/21/2017 03:06 PM, Leonardo Collado Torres wrote:
 Hi bioc-devel,

 This is a story about a bug that took me a long time to trace. The
 behaviour was really weird, so I'm sharing the story in case this
 helps others in the future. I was originally writing it to request
 help, but then I was able to find the issue ^^. The story ends right
 now with code that will reproduce the problem with '$<-' from
 IRanges/S4Vectors.




 During this Bioc cycle, frequently my package derfinder has failed to
 pass R CMD check in OSX. The error is always the same when it appears
 and sometimes it shows up in release, but not devel and viceversa.
 Right now (3/21/2017) it's visible in both
 https://urldefense.proofpoint.com/v2/url?u=http-3A__bioconductor.org_checkResults_release_bioc-2DLATEST_derfinder_morelia-2Dchecksrc.html=DwIGaQ=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=Bw-1Kqy-M_t4kmpYWTpYkt5bvj_eTpxriUM3UvtOIzQ=RS-lsygPtDdgWKAhjA2BcSLkVy9RxxshXWAJaBZa_Yc=


 and
 https://urldefense.proofpoint.com/v2/url?u=http-3A__bioconductor.org_checkResults_devel_bioc-2DLATEST_derfinder_toluca2-2Dchecksrc.html=DwIGaQ=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=Bw-1Kqy-M_t4kmpYWTpYkt5bvj_eTpxriUM3UvtOIzQ=a_K-yK7w2LEV72lpHrpp0UoKRru_7Aad74T5Uk0R-Fo=

 .
 The end of "test-all.Rout.fail" looks like this:

 Loading required package: foreach
 Loading required package: iterators
 Loading required package: locfit
 locfit 1.5-9.1 2013-03-22
 getSegments: segmenting
 getSegments: splitting
 2017-03-20 02:36:52 findRegions: smoothing
 2017-03-20 02:36:52 findRegions: identifying potential segments
 2017-03-20 02:36:52 findRegions: segmenting information
 2017-03-20 02:36:52 .getSegmentsRle: segmenting with cutoff(s)
 16.3681899295041
 2017-03-20 02:36:52 findRegions: identifying candidate regions
 2017-03-20 02:36:52 findRegions: identifying region clusters
 2017-03-20 02:36:52 findRegions: smoothing
 2017-03-20 02:36:52 findRegions: identifying potential segments
 2017-03-20 02:36:52 findRegions: segmenting information
 2017-03-20 02:36:52 .getSegmentsRle: segmenting with cutoff(s)
 19.7936614060235
 2017-03-20 02:36:52 findRegions: identifying candidate regions
 2017-03-20 02:36:52 findRegions: identifying region clusters
 2017-03-20 02:36:52 findRegions: smoothing

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

 Traceback:
  1: (function (y, x, cluster, weights, smoothFun, ...) {
 hostPackage <- environmentName(environment(smoothFun))
 requireNamespace(hostPackage)smoothed <- .runFunFormal(smoothFun,
 y = y, x = x, cluster = cluster, weights = weights, ...)if
 (any(!smoothed$smoothed)) {smoothed$fitted[!smoothed$smoothed]
 <- y[!smoothed$smoothed]}res <- Rle(smoothed$fitted)
 return(res)})(dots[[1L]][[1L]], dots[[2L]][[1L]], dots[[3L]][[1L]],
 dots[[4L]][[1L]], smoothFun = function (y, x = NULL, cluster,
 weights = NULL, minNum = 7, bpSpan = 1000, minInSpan = 0,
 verbose = TRUE) {if (is.null(dim(y))) y <-
 matrix(y, ncol = 1)if 

Re: [Bioc-devel] The story of tracing a derfinder bug on OSX that sometimes popped up, sometimes it didn't. Related to IRanges/S4Vectors '$<-'

2017-03-22 Thread Hervé Pagès

On 03/21/2017 05:28 PM, Martin Morgan wrote:

On 03/21/2017 08:21 PM, Hervé Pagès wrote:

Hi Leonardo,

Thanks for hunting down and isolating that bug! I tried to simplify
your code even more and was able to get a segfault with just:

  setClass("A", representation(stuff="numeric"))
  x <- logical(10)
  x[TRUE] <- new("A")

I get the segfault about 50% of the time on a fresh R session on Mac.
I tried this with R 3.3.3 on Mavericks, and with R devel (r72372)
on El Capitan. I get the segfault on both.

So it looks like a bug in the `[<-` primitive to me (subassignment).


Any insight from

  R -d valgrind -f herve.R

where herve.R contains the code above?


That's a little bit complicated for me at the moment. I was
actually running this code on build machines toluca2 and (upcoming)
veracruz2 and we don't have valgrind there for now. I don't have
access to other Macs so hopefully someone else will be able to help
with this.

H.



Martin



Cheers,
H.

On 03/21/2017 03:06 PM, Leonardo Collado Torres wrote:

Hi bioc-devel,

This is a story about a bug that took me a long time to trace. The
behaviour was really weird, so I'm sharing the story in case this
helps others in the future. I was originally writing it to request
help, but then I was able to find the issue ^^. The story ends right
now with code that will reproduce the problem with '$<-' from
IRanges/S4Vectors.




During this Bioc cycle, frequently my package derfinder has failed to
pass R CMD check in OSX. The error is always the same when it appears
and sometimes it shows up in release, but not devel and viceversa.
Right now (3/21/2017) it's visible in both
https://urldefense.proofpoint.com/v2/url?u=http-3A__bioconductor.org_checkResults_release_bioc-2DLATEST_derfinder_morelia-2Dchecksrc.html=DwIGaQ=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=Bw-1Kqy-M_t4kmpYWTpYkt5bvj_eTpxriUM3UvtOIzQ=RS-lsygPtDdgWKAhjA2BcSLkVy9RxxshXWAJaBZa_Yc=


and
https://urldefense.proofpoint.com/v2/url?u=http-3A__bioconductor.org_checkResults_devel_bioc-2DLATEST_derfinder_toluca2-2Dchecksrc.html=DwIGaQ=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=Bw-1Kqy-M_t4kmpYWTpYkt5bvj_eTpxriUM3UvtOIzQ=a_K-yK7w2LEV72lpHrpp0UoKRru_7Aad74T5Uk0R-Fo=

.
The end of "test-all.Rout.fail" looks like this:

Loading required package: foreach
Loading required package: iterators
Loading required package: locfit
locfit 1.5-9.1 2013-03-22
getSegments: segmenting
getSegments: splitting
2017-03-20 02:36:52 findRegions: smoothing
2017-03-20 02:36:52 findRegions: identifying potential segments
2017-03-20 02:36:52 findRegions: segmenting information
2017-03-20 02:36:52 .getSegmentsRle: segmenting with cutoff(s)
16.3681899295041
2017-03-20 02:36:52 findRegions: identifying candidate regions
2017-03-20 02:36:52 findRegions: identifying region clusters
2017-03-20 02:36:52 findRegions: smoothing
2017-03-20 02:36:52 findRegions: identifying potential segments
2017-03-20 02:36:52 findRegions: segmenting information
2017-03-20 02:36:52 .getSegmentsRle: segmenting with cutoff(s)
19.7936614060235
2017-03-20 02:36:52 findRegions: identifying candidate regions
2017-03-20 02:36:52 findRegions: identifying region clusters
2017-03-20 02:36:52 findRegions: smoothing

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

Traceback:
 1: (function (y, x, cluster, weights, smoothFun, ...) {
hostPackage <- environmentName(environment(smoothFun))
requireNamespace(hostPackage)smoothed <- .runFunFormal(smoothFun,
y = y, x = x, cluster = cluster, weights = weights, ...)if
(any(!smoothed$smoothed)) {smoothed$fitted[!smoothed$smoothed]
<- y[!smoothed$smoothed]}res <- Rle(smoothed$fitted)
return(res)})(dots[[1L]][[1L]], dots[[2L]][[1L]], dots[[3L]][[1L]],
dots[[4L]][[1L]], smoothFun = function (y, x = NULL, cluster,
weights = NULL, minNum = 7, bpSpan = 1000, minInSpan = 0,
verbose = TRUE) {if (is.null(dim(y))) y <-
matrix(y, ncol = 1)if (!is.null(weights) &&
is.null(dim(weights))) weights <- matrix(weights, ncol =
1)if (is.null(x)) x <- seq(along = y)if
(is.null(weights)) weights <- matrix(1, nrow = nrow(y),
ncol = ncol(y))Indexes <- split(seq(along = cluster), cluster)
   clusterL <- sapply(Indexes, length)smoothed <-
rep(TRUE, nrow(y))for (i in seq(along = Indexes)) {
if (verbose) if (i%%1 == 0)
cat(".")Index <- Indexes[[i]]if (clusterL[i]

= minNum & sum(rowSums(is.na(y[Index, , drop =

FALSE])) == 0) >= minNum) {nn <-
minInSpan/length(Index)for (j in 1:ncol(y)) {
sdata <- data.frame(pos = x[Index], y = y[Index,
  j], weights = weights[Index, j])  fit <-
locfit(y ˜ lp(pos, nn = nn, h = bpSpan), data =
sdata, weights = weights, family = "gaussian",
maxk = 1)  

Re: [Bioc-devel] The story of tracing a derfinder bug on OSX that sometimes popped up, sometimes it didn't. Related to IRanges/S4Vectors '$<-'

2017-03-22 Thread Leonardo Collado Torres
Awesome, thanks everyone! I'm tempted to write a blog post about this
whole story.

Best,
Leo

On Wed, Mar 22, 2017 at 6:36 AM, Martin Morgan
 wrote:
> On 03/22/2017 06:17 AM, Martin Maechler wrote:
>>>
>>> Andrzej Oleś 
>>> on Wed, 22 Mar 2017 10:29:57 +0100 writes:
>>
>>
>> > Just for the record, on R-3.3.2 Herve's code fails with the
>> following error:
>> > Error in x[TRUE] <- new("A") :
>> > incompatible types (from S4 to logical) in subassignment type fix
>>
>> yes, (of course) and I would be interested in a small
>> reproducible example which uses _valid_ code.
>> We have seen such examples with something (more complicated
>> than, but basically like)
>>
>>   df <- data.frame(x=1:5, y=5:1, m=matrix(-pi*1:30, 5,6))
>>   M <- Matrix::Matrix(exp(0:3),2)
>>   df[1:2,1:2] <- M
>>
>> which actually calls `[<-`, and then `[<-.data.frame`  and
>> always works for me but does seg.fault (in the CRAN checks of
>> package FastImputation (on 3 of the dozen platforms,
>> https://cran.r-project.org/web/checks/check_results_FastImputation.html
>>
>> one of them is
>>
>>
>> https://www.r-project.org/nosvn/R.check/r-devel-macos-x86_64-clang/FastImputation-00check.html
>>
>> I strongly suspect this is the same bug as yours, but for a case
>> where the correct behavior is *not* giving an error.
>>
>> I have also written and shown  Herve's example  to the R-core team.
>
>
> On Linux, if I run Leonardo's or Martin's example under gctorture(TRUE) I
> see a PROTECT problem; I don't see this with Herve's code, and I don't think
> his code goes through this execution path.
>
> e.g.
>
>> library(Matrix)
>> gctorture(TRUE)
>>   df <- data.frame(x=1:5, y=5:1, m=matrix(-pi*1:30, 5,6))
>>   M <- Matrix::Matrix(exp(0:3),2)
>>   df[1:2,1:2] <- M
> Error in `[<-.data.frame`(`*tmp*`, 1:2, 1:2, value =  "dgeMatrix">) :
>   unimplemented type 'integer' in 'coerceToInteger'
>
> This is addressed in r72383.
>
> R-devel$ svn diff -c72383
> Index: src/main/array.c
> ===
> --- src/main/array.c(revision 72382)
> +++ src/main/array.c(revision 72383)
> @@ -436,8 +436,12 @@
> DispatchOrEval(call, op, "length", args, rho, , 0, 1)) {
> if (length(ans) == 1 && TYPEOF(ans) == REALSXP) {
> double d = REAL(ans)[0];
> -   if (R_FINITE(d) && d >= 0. && d <= INT_MAX && floor(d) == d)
> -   return coerceVector(ans, INTSXP);
> +   if (R_FINITE(d) && d >= 0. && d <= INT_MAX && floor(d) == d) {
> +PROTECT(ans);
> +ans = coerceVector(ans, INTSXP);
> +UNPROTECT(1);
> +return(ans);
> +}
> }
> return(ans);
>  }
>
>
> Martin Morgan
>
>
>>
>> Unfortunately, I have no platform where I can trigger the bug.
>> Martin
>>
>>
>>
>> > Cheers,
>> > Andrzej
>>
>>
>>
>> > On Wed, Mar 22, 2017 at 1:28 AM, Martin Morgan <
>> > martin.mor...@roswellpark.org> wrote:
>>
>> >> On 03/21/2017 08:21 PM, Hervé Pagès wrote:
>> >>
>> >>> Hi Leonardo,
>> >>>
>> >>> Thanks for hunting down and isolating that bug! I tried to
>> simplify
>> >>> your code even more and was able to get a segfault with just:
>> >>>
>> >>> setClass("A", representation(stuff="numeric"))
>> >>> x <- logical(10)
>> >>> x[TRUE] <- new("A")
>> >>>
>> >>> I get the segfault about 50% of the time on a fresh R session on
>> Mac.
>> >>> I tried this with R 3.3.3 on Mavericks, and with R devel (r72372)
>> >>> on El Capitan. I get the segfault on both.
>> >>>
>> >>> So it looks like a bug in the `[<-` primitive to me
>> (subassignment).
>> >>>
>> >>
>> >> Any insight from
>> >>
>> >> R -d valgrind -f herve.R
>> >>
>> >> where herve.R contains the code above?
>> >>
>> >> Martin
>> >>
>> >>
>> >>
>> >>> Cheers,
>> >>> H.
>> >>>
>> >>> On 03/21/2017 03:06 PM, Leonardo Collado Torres wrote:
>> >>>
>>  Hi bioc-devel,
>> 
>>  This is a story about a bug that took me a long time to trace.
>> The
>>  behaviour was really weird, so I'm sharing the story in case this
>>  helps others in the future. I was originally writing it to
>> request
>>  help, but then I was able to find the issue ^^. The story ends
>> right
>>  now with code that will reproduce the problem with '$<-' from
>>  IRanges/S4Vectors.
>> 
>> 
>> 
>> 
>>  During this Bioc cycle, frequently my package derfinder has
>> failed to
>>  pass R CMD check in OSX. The error is always the same when it
>> appears
>>  and sometimes it shows up in release, but not devel and
>> viceversa.
>>  Right now (3/21/2017) it's visible in both
>>  

Re: [Bioc-devel] The story of tracing a derfinder bug on OSX that sometimes popped up, sometimes it didn't. Related to IRanges/S4Vectors '$<-'

2017-03-22 Thread Martin Morgan

On 03/22/2017 06:17 AM, Martin Maechler wrote:

Andrzej Oleś 
on Wed, 22 Mar 2017 10:29:57 +0100 writes:


> Just for the record, on R-3.3.2 Herve's code fails with the following 
error:
> Error in x[TRUE] <- new("A") :
> incompatible types (from S4 to logical) in subassignment type fix

yes, (of course) and I would be interested in a small
reproducible example which uses _valid_ code.
We have seen such examples with something (more complicated
than, but basically like)

  df <- data.frame(x=1:5, y=5:1, m=matrix(-pi*1:30, 5,6))
  M <- Matrix::Matrix(exp(0:3),2)
  df[1:2,1:2] <- M

which actually calls `[<-`, and then `[<-.data.frame`  and
always works for me but does seg.fault (in the CRAN checks of
package FastImputation (on 3 of the dozen platforms,
https://cran.r-project.org/web/checks/check_results_FastImputation.html

one of them is

 
https://www.r-project.org/nosvn/R.check/r-devel-macos-x86_64-clang/FastImputation-00check.html

I strongly suspect this is the same bug as yours, but for a case
where the correct behavior is *not* giving an error.

I have also written and shown  Herve's example  to the R-core team.


On Linux, if I run Leonardo's or Martin's example under gctorture(TRUE) 
I see a PROTECT problem; I don't see this with Herve's code, and I don't 
think his code goes through this execution path.


e.g.

> library(Matrix)
> gctorture(TRUE)
>   df <- data.frame(x=1:5, y=5:1, m=matrix(-pi*1:30, 5,6))
>   M <- Matrix::Matrix(exp(0:3),2)
>   df[1:2,1:2] <- M
Error in `[<-.data.frame`(`*tmp*`, 1:2, 1:2, value = "dgeMatrix">) :

  unimplemented type 'integer' in 'coerceToInteger'

This is addressed in r72383.

R-devel$ svn diff -c72383
Index: src/main/array.c
===
--- src/main/array.c(revision 72382)
+++ src/main/array.c(revision 72383)
@@ -436,8 +436,12 @@
DispatchOrEval(call, op, "length", args, rho, , 0, 1)) {
if (length(ans) == 1 && TYPEOF(ans) == REALSXP) {
double d = REAL(ans)[0];
-   if (R_FINITE(d) && d >= 0. && d <= INT_MAX && floor(d) == d)
-   return coerceVector(ans, INTSXP);
+   if (R_FINITE(d) && d >= 0. && d <= INT_MAX && floor(d) == d) {
+PROTECT(ans);
+ans = coerceVector(ans, INTSXP);
+UNPROTECT(1);
+return(ans);
+}
}
return(ans);
 }


Martin Morgan



Unfortunately, I have no platform where I can trigger the bug.
Martin



> Cheers,
> Andrzej



> On Wed, Mar 22, 2017 at 1:28 AM, Martin Morgan <
> martin.mor...@roswellpark.org> wrote:

>> On 03/21/2017 08:21 PM, Hervé Pagès wrote:
>>
>>> Hi Leonardo,
>>>
>>> Thanks for hunting down and isolating that bug! I tried to simplify
>>> your code even more and was able to get a segfault with just:
>>>
>>> setClass("A", representation(stuff="numeric"))
>>> x <- logical(10)
>>> x[TRUE] <- new("A")
>>>
>>> I get the segfault about 50% of the time on a fresh R session on Mac.
>>> I tried this with R 3.3.3 on Mavericks, and with R devel (r72372)
>>> on El Capitan. I get the segfault on both.
>>>
>>> So it looks like a bug in the `[<-` primitive to me (subassignment).
>>>
>>
>> Any insight from
>>
>> R -d valgrind -f herve.R
>>
>> where herve.R contains the code above?
>>
>> Martin
>>
>>
>>
>>> Cheers,
>>> H.
>>>
>>> On 03/21/2017 03:06 PM, Leonardo Collado Torres wrote:
>>>
 Hi bioc-devel,

 This is a story about a bug that took me a long time to trace. The
 behaviour was really weird, so I'm sharing the story in case this
 helps others in the future. I was originally writing it to request
 help, but then I was able to find the issue ^^. The story ends right
 now with code that will reproduce the problem with '$<-' from
 IRanges/S4Vectors.




 During this Bioc cycle, frequently my package derfinder has failed to
 pass R CMD check in OSX. The error is always the same when it appears
 and sometimes it shows up in release, but not devel and viceversa.
 Right now (3/21/2017) it's visible in both
 https://urldefense.proofpoint.com/v2/url?u=http-3A__biocondu
 ctor.org_checkResults_release_bioc-2DLATEST_derfinder_
 morelia-2Dchecksrc.html=DwIGaQ=eRAMFD45gAfqt84VtBcfh
 Q=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=Bw-1Kqy-M_
 t4kmpYWTpYkt5bvj_eTpxriUM3UvtOIzQ=RS-lsygPtDdgWKAhjA2BcSLk
 Vy9RxxshXWAJaBZa_Yc=

 and
 https://urldefense.proofpoint.com/v2/url?u=http-3A__biocondu
 ctor.org_checkResults_devel_bioc-2DLATEST_derfinder_toluca
 2-2Dchecksrc.html=DwIGaQ=eRAMFD45gAfqt84VtBcfhQ=BK7q3X
 

Re: [Bioc-devel] The story of tracing a derfinder bug on OSX that sometimes popped up, sometimes it didn't. Related to IRanges/S4Vectors '$<-'

2017-03-22 Thread Martin Maechler
> Andrzej Oleś 
> on Wed, 22 Mar 2017 10:29:57 +0100 writes:

> Just for the record, on R-3.3.2 Herve's code fails with the following 
error:
> Error in x[TRUE] <- new("A") :
> incompatible types (from S4 to logical) in subassignment type fix

yes, (of course) and I would be interested in a small
reproducible example which uses _valid_ code.
We have seen such examples with something (more complicated
than, but basically like)

  df <- data.frame(x=1:5, y=5:1, m=matrix(-pi*1:30, 5,6))
  M <- Matrix::Matrix(exp(0:3),2)
  df[1:2,1:2] <- M

which actually calls `[<-`, and then `[<-.data.frame`  and
always works for me but does seg.fault (in the CRAN checks of
package FastImputation (on 3 of the dozen platforms,
https://cran.r-project.org/web/checks/check_results_FastImputation.html

one of them is

 
https://www.r-project.org/nosvn/R.check/r-devel-macos-x86_64-clang/FastImputation-00check.html

I strongly suspect this is the same bug as yours, but for a case
where the correct behavior is *not* giving an error.

I have also written and shown  Herve's example  to the R-core team.

Unfortunately, I have no platform where I can trigger the bug.
Martin



> Cheers,
> Andrzej



> On Wed, Mar 22, 2017 at 1:28 AM, Martin Morgan <
> martin.mor...@roswellpark.org> wrote:

>> On 03/21/2017 08:21 PM, Hervé Pagès wrote:
>> 
>>> Hi Leonardo,
>>> 
>>> Thanks for hunting down and isolating that bug! I tried to simplify
>>> your code even more and was able to get a segfault with just:
>>> 
>>> setClass("A", representation(stuff="numeric"))
>>> x <- logical(10)
>>> x[TRUE] <- new("A")
>>> 
>>> I get the segfault about 50% of the time on a fresh R session on Mac.
>>> I tried this with R 3.3.3 on Mavericks, and with R devel (r72372)
>>> on El Capitan. I get the segfault on both.
>>> 
>>> So it looks like a bug in the `[<-` primitive to me (subassignment).
>>> 
>> 
>> Any insight from
>> 
>> R -d valgrind -f herve.R
>> 
>> where herve.R contains the code above?
>> 
>> Martin
>> 
>> 
>> 
>>> Cheers,
>>> H.
>>> 
>>> On 03/21/2017 03:06 PM, Leonardo Collado Torres wrote:
>>> 
 Hi bioc-devel,
 
 This is a story about a bug that took me a long time to trace. The
 behaviour was really weird, so I'm sharing the story in case this
 helps others in the future. I was originally writing it to request
 help, but then I was able to find the issue ^^. The story ends right
 now with code that will reproduce the problem with '$<-' from
 IRanges/S4Vectors.
 
 
 
 
 During this Bioc cycle, frequently my package derfinder has failed to
 pass R CMD check in OSX. The error is always the same when it appears
 and sometimes it shows up in release, but not devel and viceversa.
 Right now (3/21/2017) it's visible in both
 https://urldefense.proofpoint.com/v2/url?u=http-3A__biocondu
 ctor.org_checkResults_release_bioc-2DLATEST_derfinder_
 morelia-2Dchecksrc.html=DwIGaQ=eRAMFD45gAfqt84VtBcfh
 Q=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=Bw-1Kqy-M_
 t4kmpYWTpYkt5bvj_eTpxriUM3UvtOIzQ=RS-lsygPtDdgWKAhjA2BcSLk
 Vy9RxxshXWAJaBZa_Yc=
 
 and
 https://urldefense.proofpoint.com/v2/url?u=http-3A__biocondu
 ctor.org_checkResults_devel_bioc-2DLATEST_derfinder_toluca
 2-2Dchecksrc.html=DwIGaQ=eRAMFD45gAfqt84VtBcfhQ=BK7q3X
 eAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=Bw-1Kqy-M_
 t4kmpYWTpYkt5bvj_eTpxriUM3UvtOIzQ=a_K-yK7w2LEV72lpHrpp0UoK
 Rru_7Aad74T5Uk0R-Fo=
 .
 The end of "test-all.Rout.fail" looks like this:
 
 Loading required package: foreach
 Loading required package: iterators
 Loading required package: locfit
 locfit 1.5-9.1 2013-03-22
 getSegments: segmenting
 getSegments: splitting
 2017-03-20 02:36:52 findRegions: smoothing
 2017-03-20 02:36:52 findRegions: identifying potential segments
 2017-03-20 02:36:52 findRegions: segmenting information
 2017-03-20 02:36:52 .getSegmentsRle: segmenting with cutoff(s)
 16.3681899295041
 2017-03-20 02:36:52 findRegions: identifying candidate regions
 2017-03-20 02:36:52 findRegions: identifying region clusters
 2017-03-20 02:36:52 findRegions: smoothing
 2017-03-20 02:36:52 findRegions: identifying potential segments
 2017-03-20 02:36:52 findRegions: segmenting information
 2017-03-20 02:36:52 .getSegmentsRle: segmenting with cutoff(s)
 19.7936614060235
 2017-03-20 02:36:52 findRegions: identifying candidate regions
 2017-03-20 02:36:52 findRegions: identifying region clusters
 2017-03-20 02:36:52 

Re: [Bioc-devel] The story of tracing a derfinder bug on OSX that sometimes popped up, sometimes it didn't. Related to IRanges/S4Vectors '$<-'

2017-03-22 Thread Andrzej Oleś
On Wed, Mar 22, 2017 at 10:29 AM, Andrzej Oleś 
wrote:

> Just for the record, on R-3.3.2 Herve's code fails with the following
> error:
>
> Error in x[TRUE] <- new("A") :
>   incompatible types (from S4 to logical) in subassignment type fix
>

Quick update: I also get the above error on my Linux box under R-3.3.3.

Andrzej

[[alternative HTML version deleted]]

___
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel

Re: [Bioc-devel] The story of tracing a derfinder bug on OSX that sometimes popped up, sometimes it didn't. Related to IRanges/S4Vectors '$<-'

2017-03-22 Thread Andrzej Oleś
Just for the record, on R-3.3.2 Herve's code fails with the following error:

Error in x[TRUE] <- new("A") :
  incompatible types (from S4 to logical) in subassignment type fix


Cheers,
Andrzej



On Wed, Mar 22, 2017 at 1:28 AM, Martin Morgan <
martin.mor...@roswellpark.org> wrote:

> On 03/21/2017 08:21 PM, Hervé Pagès wrote:
>
>> Hi Leonardo,
>>
>> Thanks for hunting down and isolating that bug! I tried to simplify
>> your code even more and was able to get a segfault with just:
>>
>>   setClass("A", representation(stuff="numeric"))
>>   x <- logical(10)
>>   x[TRUE] <- new("A")
>>
>> I get the segfault about 50% of the time on a fresh R session on Mac.
>> I tried this with R 3.3.3 on Mavericks, and with R devel (r72372)
>> on El Capitan. I get the segfault on both.
>>
>> So it looks like a bug in the `[<-` primitive to me (subassignment).
>>
>
> Any insight from
>
>   R -d valgrind -f herve.R
>
> where herve.R contains the code above?
>
> Martin
>
>
>
>> Cheers,
>> H.
>>
>> On 03/21/2017 03:06 PM, Leonardo Collado Torres wrote:
>>
>>> Hi bioc-devel,
>>>
>>> This is a story about a bug that took me a long time to trace. The
>>> behaviour was really weird, so I'm sharing the story in case this
>>> helps others in the future. I was originally writing it to request
>>> help, but then I was able to find the issue ^^. The story ends right
>>> now with code that will reproduce the problem with '$<-' from
>>> IRanges/S4Vectors.
>>>
>>>
>>>
>>>
>>> During this Bioc cycle, frequently my package derfinder has failed to
>>> pass R CMD check in OSX. The error is always the same when it appears
>>> and sometimes it shows up in release, but not devel and viceversa.
>>> Right now (3/21/2017) it's visible in both
>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__biocondu
>>> ctor.org_checkResults_release_bioc-2DLATEST_derfinder_
>>> morelia-2Dchecksrc.html=DwIGaQ=eRAMFD45gAfqt84VtBcfh
>>> Q=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=Bw-1Kqy-M_
>>> t4kmpYWTpYkt5bvj_eTpxriUM3UvtOIzQ=RS-lsygPtDdgWKAhjA2BcSLk
>>> Vy9RxxshXWAJaBZa_Yc=
>>>
>>> and
>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__biocondu
>>> ctor.org_checkResults_devel_bioc-2DLATEST_derfinder_toluca
>>> 2-2Dchecksrc.html=DwIGaQ=eRAMFD45gAfqt84VtBcfhQ=BK7q3X
>>> eAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=Bw-1Kqy-M_
>>> t4kmpYWTpYkt5bvj_eTpxriUM3UvtOIzQ=a_K-yK7w2LEV72lpHrpp0UoK
>>> Rru_7Aad74T5Uk0R-Fo=
>>> .
>>> The end of "test-all.Rout.fail" looks like this:
>>>
>>> Loading required package: foreach
>>> Loading required package: iterators
>>> Loading required package: locfit
>>> locfit 1.5-9.1 2013-03-22
>>> getSegments: segmenting
>>> getSegments: splitting
>>> 2017-03-20 02:36:52 findRegions: smoothing
>>> 2017-03-20 02:36:52 findRegions: identifying potential segments
>>> 2017-03-20 02:36:52 findRegions: segmenting information
>>> 2017-03-20 02:36:52 .getSegmentsRle: segmenting with cutoff(s)
>>> 16.3681899295041
>>> 2017-03-20 02:36:52 findRegions: identifying candidate regions
>>> 2017-03-20 02:36:52 findRegions: identifying region clusters
>>> 2017-03-20 02:36:52 findRegions: smoothing
>>> 2017-03-20 02:36:52 findRegions: identifying potential segments
>>> 2017-03-20 02:36:52 findRegions: segmenting information
>>> 2017-03-20 02:36:52 .getSegmentsRle: segmenting with cutoff(s)
>>> 19.7936614060235
>>> 2017-03-20 02:36:52 findRegions: identifying candidate regions
>>> 2017-03-20 02:36:52 findRegions: identifying region clusters
>>> 2017-03-20 02:36:52 findRegions: smoothing
>>>
>>>  *** caught segfault ***
>>> address 0x7f87d2f917e0, cause 'memory not mapped'
>>>
>>> Traceback:
>>>  1: (function (y, x, cluster, weights, smoothFun, ...) {
>>> hostPackage <- environmentName(environment(smoothFun))
>>> requireNamespace(hostPackage)smoothed <- .runFunFormal(smoothFun,
>>> y = y, x = x, cluster = cluster, weights = weights, ...)if
>>> (any(!smoothed$smoothed)) {smoothed$fitted[!smoothed$smoothed]
>>> <- y[!smoothed$smoothed]}res <- Rle(smoothed$fitted)
>>> return(res)})(dots[[1L]][[1L]], dots[[2L]][[1L]], dots[[3L]][[1L]],
>>> dots[[4L]][[1L]], smoothFun = function (y, x = NULL, cluster,
>>> weights = NULL, minNum = 7, bpSpan = 1000, minInSpan = 0,
>>> verbose = TRUE) {if (is.null(dim(y))) y <-
>>> matrix(y, ncol = 1)if (!is.null(weights) &&
>>> is.null(dim(weights))) weights <- matrix(weights, ncol =
>>> 1)if (is.null(x)) x <- seq(along = y)if
>>> (is.null(weights)) weights <- matrix(1, nrow = nrow(y),
>>> ncol = ncol(y))Indexes <- split(seq(along = cluster), cluster)
>>>clusterL <- sapply(Indexes, length)smoothed <-
>>> rep(TRUE, nrow(y))for (i in seq(along = Indexes)) {
>>> if (verbose) if (i%%1 == 0)
>>> cat(".")Index <- Indexes[[i]]if (clusterL[i]
>>>
 = minNum & sum(rowSums(is.na(y[Index, , drop =

>>> FALSE])) == 0) 

Re: [Bioc-devel] The story of tracing a derfinder bug on OSX that sometimes popped up, sometimes it didn't. Related to IRanges/S4Vectors '$<-'

2017-03-21 Thread Martin Morgan

On 03/21/2017 08:21 PM, Hervé Pagès wrote:

Hi Leonardo,

Thanks for hunting down and isolating that bug! I tried to simplify
your code even more and was able to get a segfault with just:

  setClass("A", representation(stuff="numeric"))
  x <- logical(10)
  x[TRUE] <- new("A")

I get the segfault about 50% of the time on a fresh R session on Mac.
I tried this with R 3.3.3 on Mavericks, and with R devel (r72372)
on El Capitan. I get the segfault on both.

So it looks like a bug in the `[<-` primitive to me (subassignment).


Any insight from

  R -d valgrind -f herve.R

where herve.R contains the code above?

Martin



Cheers,
H.

On 03/21/2017 03:06 PM, Leonardo Collado Torres wrote:

Hi bioc-devel,

This is a story about a bug that took me a long time to trace. The
behaviour was really weird, so I'm sharing the story in case this
helps others in the future. I was originally writing it to request
help, but then I was able to find the issue ^^. The story ends right
now with code that will reproduce the problem with '$<-' from
IRanges/S4Vectors.




During this Bioc cycle, frequently my package derfinder has failed to
pass R CMD check in OSX. The error is always the same when it appears
and sometimes it shows up in release, but not devel and viceversa.
Right now (3/21/2017) it's visible in both
https://urldefense.proofpoint.com/v2/url?u=http-3A__bioconductor.org_checkResults_release_bioc-2DLATEST_derfinder_morelia-2Dchecksrc.html=DwIGaQ=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=Bw-1Kqy-M_t4kmpYWTpYkt5bvj_eTpxriUM3UvtOIzQ=RS-lsygPtDdgWKAhjA2BcSLkVy9RxxshXWAJaBZa_Yc=

and
https://urldefense.proofpoint.com/v2/url?u=http-3A__bioconductor.org_checkResults_devel_bioc-2DLATEST_derfinder_toluca2-2Dchecksrc.html=DwIGaQ=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=Bw-1Kqy-M_t4kmpYWTpYkt5bvj_eTpxriUM3UvtOIzQ=a_K-yK7w2LEV72lpHrpp0UoKRru_7Aad74T5Uk0R-Fo=
.
The end of "test-all.Rout.fail" looks like this:

Loading required package: foreach
Loading required package: iterators
Loading required package: locfit
locfit 1.5-9.1 2013-03-22
getSegments: segmenting
getSegments: splitting
2017-03-20 02:36:52 findRegions: smoothing
2017-03-20 02:36:52 findRegions: identifying potential segments
2017-03-20 02:36:52 findRegions: segmenting information
2017-03-20 02:36:52 .getSegmentsRle: segmenting with cutoff(s)
16.3681899295041
2017-03-20 02:36:52 findRegions: identifying candidate regions
2017-03-20 02:36:52 findRegions: identifying region clusters
2017-03-20 02:36:52 findRegions: smoothing
2017-03-20 02:36:52 findRegions: identifying potential segments
2017-03-20 02:36:52 findRegions: segmenting information
2017-03-20 02:36:52 .getSegmentsRle: segmenting with cutoff(s)
19.7936614060235
2017-03-20 02:36:52 findRegions: identifying candidate regions
2017-03-20 02:36:52 findRegions: identifying region clusters
2017-03-20 02:36:52 findRegions: smoothing

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

Traceback:
 1: (function (y, x, cluster, weights, smoothFun, ...) {
hostPackage <- environmentName(environment(smoothFun))
requireNamespace(hostPackage)smoothed <- .runFunFormal(smoothFun,
y = y, x = x, cluster = cluster, weights = weights, ...)if
(any(!smoothed$smoothed)) {smoothed$fitted[!smoothed$smoothed]
<- y[!smoothed$smoothed]}res <- Rle(smoothed$fitted)
return(res)})(dots[[1L]][[1L]], dots[[2L]][[1L]], dots[[3L]][[1L]],
dots[[4L]][[1L]], smoothFun = function (y, x = NULL, cluster,
weights = NULL, minNum = 7, bpSpan = 1000, minInSpan = 0,
verbose = TRUE) {if (is.null(dim(y))) y <-
matrix(y, ncol = 1)if (!is.null(weights) &&
is.null(dim(weights))) weights <- matrix(weights, ncol =
1)if (is.null(x)) x <- seq(along = y)if
(is.null(weights)) weights <- matrix(1, nrow = nrow(y),
ncol = ncol(y))Indexes <- split(seq(along = cluster), cluster)
   clusterL <- sapply(Indexes, length)smoothed <-
rep(TRUE, nrow(y))for (i in seq(along = Indexes)) {
if (verbose) if (i%%1 == 0)
cat(".")Index <- Indexes[[i]]if (clusterL[i]

= minNum & sum(rowSums(is.na(y[Index, , drop =

FALSE])) == 0) >= minNum) {nn <-
minInSpan/length(Index)for (j in 1:ncol(y)) {
sdata <- data.frame(pos = x[Index], y = y[Index,
  j], weights = weights[Index, j])  fit <-
locfit(y ˜ lp(pos, nn = nn, h = bpSpan), data =
sdata, weights = weights, family = "gaussian",
maxk = 1)  pp <- preplot(fit, where = "data", band
= "local", newdata = data.frame(pos = x[Index]))
   y[Index, j] <- pp$trans(pp$fit)}
}else {y[Index, ] <- NA
smoothed[Index] <- FALSE}}
return(list(fitted = y, smoothed = smoothed, 

Re: [Bioc-devel] The story of tracing a derfinder bug on OSX that sometimes popped up, sometimes it didn't. Related to IRanges/S4Vectors '$<-'

2017-03-21 Thread Hervé Pagès

Hi Leonardo,

Thanks for hunting down and isolating that bug! I tried to simplify
your code even more and was able to get a segfault with just:

  setClass("A", representation(stuff="numeric"))
  x <- logical(10)
  x[TRUE] <- new("A")

I get the segfault about 50% of the time on a fresh R session on Mac.
I tried this with R 3.3.3 on Mavericks, and with R devel (r72372)
on El Capitan. I get the segfault on both.

So it looks like a bug in the `[<-` primitive to me (subassignment).

Cheers,
H.

On 03/21/2017 03:06 PM, Leonardo Collado Torres wrote:

Hi bioc-devel,

This is a story about a bug that took me a long time to trace. The
behaviour was really weird, so I'm sharing the story in case this
helps others in the future. I was originally writing it to request
help, but then I was able to find the issue ^^. The story ends right
now with code that will reproduce the problem with '$<-' from
IRanges/S4Vectors.




During this Bioc cycle, frequently my package derfinder has failed to
pass R CMD check in OSX. The error is always the same when it appears
and sometimes it shows up in release, but not devel and viceversa.
Right now (3/21/2017) it's visible in both
https://urldefense.proofpoint.com/v2/url?u=http-3A__bioconductor.org_checkResults_release_bioc-2DLATEST_derfinder_morelia-2Dchecksrc.html=DwIGaQ=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=Bw-1Kqy-M_t4kmpYWTpYkt5bvj_eTpxriUM3UvtOIzQ=RS-lsygPtDdgWKAhjA2BcSLkVy9RxxshXWAJaBZa_Yc=
and 
https://urldefense.proofpoint.com/v2/url?u=http-3A__bioconductor.org_checkResults_devel_bioc-2DLATEST_derfinder_toluca2-2Dchecksrc.html=DwIGaQ=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=Bw-1Kqy-M_t4kmpYWTpYkt5bvj_eTpxriUM3UvtOIzQ=a_K-yK7w2LEV72lpHrpp0UoKRru_7Aad74T5Uk0R-Fo=
 .
The end of "test-all.Rout.fail" looks like this:

Loading required package: foreach
Loading required package: iterators
Loading required package: locfit
locfit 1.5-9.1 2013-03-22
getSegments: segmenting
getSegments: splitting
2017-03-20 02:36:52 findRegions: smoothing
2017-03-20 02:36:52 findRegions: identifying potential segments
2017-03-20 02:36:52 findRegions: segmenting information
2017-03-20 02:36:52 .getSegmentsRle: segmenting with cutoff(s) 16.3681899295041
2017-03-20 02:36:52 findRegions: identifying candidate regions
2017-03-20 02:36:52 findRegions: identifying region clusters
2017-03-20 02:36:52 findRegions: smoothing
2017-03-20 02:36:52 findRegions: identifying potential segments
2017-03-20 02:36:52 findRegions: segmenting information
2017-03-20 02:36:52 .getSegmentsRle: segmenting with cutoff(s) 19.7936614060235
2017-03-20 02:36:52 findRegions: identifying candidate regions
2017-03-20 02:36:52 findRegions: identifying region clusters
2017-03-20 02:36:52 findRegions: smoothing

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

Traceback:
 1: (function (y, x, cluster, weights, smoothFun, ...) {
hostPackage <- environmentName(environment(smoothFun))
requireNamespace(hostPackage)smoothed <- .runFunFormal(smoothFun,
y = y, x = x, cluster = cluster, weights = weights, ...)if
(any(!smoothed$smoothed)) {smoothed$fitted[!smoothed$smoothed]
<- y[!smoothed$smoothed]}res <- Rle(smoothed$fitted)
return(res)})(dots[[1L]][[1L]], dots[[2L]][[1L]], dots[[3L]][[1L]],
dots[[4L]][[1L]], smoothFun = function (y, x = NULL, cluster,
weights = NULL, minNum = 7, bpSpan = 1000, minInSpan = 0,
verbose = TRUE) {if (is.null(dim(y))) y <-
matrix(y, ncol = 1)if (!is.null(weights) &&
is.null(dim(weights))) weights <- matrix(weights, ncol =
1)if (is.null(x)) x <- seq(along = y)if
(is.null(weights)) weights <- matrix(1, nrow = nrow(y),
ncol = ncol(y))Indexes <- split(seq(along = cluster), cluster)
   clusterL <- sapply(Indexes, length)smoothed <-
rep(TRUE, nrow(y))for (i in seq(along = Indexes)) {
if (verbose) if (i%%1 == 0)
cat(".")Index <- Indexes[[i]]if (clusterL[i]

= minNum & sum(rowSums(is.na(y[Index, , drop =

FALSE])) == 0) >= minNum) {nn <-
minInSpan/length(Index)for (j in 1:ncol(y)) {
sdata <- data.frame(pos = x[Index], y = y[Index,
  j], weights = weights[Index, j])  fit <-
locfit(y ˜ lp(pos, nn = nn, h = bpSpan), data =
sdata, weights = weights, family = "gaussian",
maxk = 1)  pp <- preplot(fit, where = "data", band
= "local", newdata = data.frame(pos = x[Index]))
   y[Index, j] <- pp$trans(pp$fit)}
}else {y[Index, ] <- NA
smoothed[Index] <- FALSE}}
return(list(fitted = y, smoothed = smoothed, smoother = "locfit"))
}, verbose = TRUE, minNum = 1435)
 2: .mapply(.FUN, dots, .MoreArgs)
 3: FUN(...)
 4: doTryCatch(return(expr), name, 

[Bioc-devel] The story of tracing a derfinder bug on OSX that sometimes popped up, sometimes it didn't. Related to IRanges/S4Vectors '$<-'

2017-03-21 Thread Leonardo Collado Torres
Hi bioc-devel,

This is a story about a bug that took me a long time to trace. The
behaviour was really weird, so I'm sharing the story in case this
helps others in the future. I was originally writing it to request
help, but then I was able to find the issue ^^. The story ends right
now with code that will reproduce the problem with '$<-' from
IRanges/S4Vectors.




During this Bioc cycle, frequently my package derfinder has failed to
pass R CMD check in OSX. The error is always the same when it appears
and sometimes it shows up in release, but not devel and viceversa.
Right now (3/21/2017) it's visible in both
http://bioconductor.org/checkResults/release/bioc-LATEST/derfinder/morelia-checksrc.html
and 
http://bioconductor.org/checkResults/devel/bioc-LATEST/derfinder/toluca2-checksrc.html.
The end of "test-all.Rout.fail" looks like this:

Loading required package: foreach
Loading required package: iterators
Loading required package: locfit
locfit 1.5-9.1 2013-03-22
getSegments: segmenting
getSegments: splitting
2017-03-20 02:36:52 findRegions: smoothing
2017-03-20 02:36:52 findRegions: identifying potential segments
2017-03-20 02:36:52 findRegions: segmenting information
2017-03-20 02:36:52 .getSegmentsRle: segmenting with cutoff(s) 16.3681899295041
2017-03-20 02:36:52 findRegions: identifying candidate regions
2017-03-20 02:36:52 findRegions: identifying region clusters
2017-03-20 02:36:52 findRegions: smoothing
2017-03-20 02:36:52 findRegions: identifying potential segments
2017-03-20 02:36:52 findRegions: segmenting information
2017-03-20 02:36:52 .getSegmentsRle: segmenting with cutoff(s) 19.7936614060235
2017-03-20 02:36:52 findRegions: identifying candidate regions
2017-03-20 02:36:52 findRegions: identifying region clusters
2017-03-20 02:36:52 findRegions: smoothing

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

Traceback:
 1: (function (y, x, cluster, weights, smoothFun, ...) {
hostPackage <- environmentName(environment(smoothFun))
requireNamespace(hostPackage)smoothed <- .runFunFormal(smoothFun,
y = y, x = x, cluster = cluster, weights = weights, ...)if
(any(!smoothed$smoothed)) {smoothed$fitted[!smoothed$smoothed]
<- y[!smoothed$smoothed]}res <- Rle(smoothed$fitted)
return(res)})(dots[[1L]][[1L]], dots[[2L]][[1L]], dots[[3L]][[1L]],
dots[[4L]][[1L]], smoothFun = function (y, x = NULL, cluster,
weights = NULL, minNum = 7, bpSpan = 1000, minInSpan = 0,
verbose = TRUE) {if (is.null(dim(y))) y <-
matrix(y, ncol = 1)if (!is.null(weights) &&
is.null(dim(weights))) weights <- matrix(weights, ncol =
1)if (is.null(x)) x <- seq(along = y)if
(is.null(weights)) weights <- matrix(1, nrow = nrow(y),
ncol = ncol(y))Indexes <- split(seq(along = cluster), cluster)
   clusterL <- sapply(Indexes, length)smoothed <-
rep(TRUE, nrow(y))for (i in seq(along = Indexes)) {
if (verbose) if (i%%1 == 0)
cat(".")Index <- Indexes[[i]]if (clusterL[i]
>= minNum & sum(rowSums(is.na(y[Index, , drop =
FALSE])) == 0) >= minNum) {nn <-
minInSpan/length(Index)for (j in 1:ncol(y)) {
sdata <- data.frame(pos = x[Index], y = y[Index,
  j], weights = weights[Index, j])  fit <-
locfit(y ˜ lp(pos, nn = nn, h = bpSpan), data =
sdata, weights = weights, family = "gaussian",
maxk = 1)  pp <- preplot(fit, where = "data", band
= "local", newdata = data.frame(pos = x[Index]))
   y[Index, j] <- pp$trans(pp$fit)}
}else {y[Index, ] <- NA
smoothed[Index] <- FALSE}}
return(list(fitted = y, smoothed = smoothed, smoother = "locfit"))
}, verbose = TRUE, minNum = 1435)
 2: .mapply(.FUN, dots, .MoreArgs)
 3: FUN(...)
 4: doTryCatch(return(expr), name, parentenv, handler)
 5: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 6: tryCatchList(expr, classes, parentenv, handlers)
 7: tryCatch({FUN(...)}, error = handle_error)
 8: withCallingHandlers({tryCatch({FUN(...)}, error =
handle_error)}, warning = handle_warning)
 9: FUN(X[[i]], ...)
10: lapply(X, FUN, ...)
11: bplapply(X = seq_along(ddd[[1L]]), wrap, .FUN = FUN, .ddd = ddd,
  .MoreArgs = MoreArgs, BPREDO = BPREDO, BPPARAM = BPPARAM)
12: bplapply(X = seq_along(ddd[[1L]]), wrap, .FUN = FUN, .ddd = ddd,
  .MoreArgs = MoreArgs, BPREDO = BPREDO, BPPARAM = BPPARAM)
13: bpmapply(.smoothFstatsFun, fstatsChunks, posChunks, clusterChunks,
weightChunks, MoreArgs = list(smoothFun = smoothFunction,
...), BPPARAM = BPPARAM)
14: bpmapply(.smoothFstatsFun, fstatsChunks, posChunks, clusterChunks,
weightChunks, MoreArgs = list(smoothFun = smoothFunction,
...), BPPARAM = BPPARAM)
15: .smootherFstats(fstats = fstats, position = position, weights =