From tom@@@k@||ber@ @end|ng |rom gm@||@com  Fri Mar  6 09:40:57 2020
From: tom@@@k@||ber@ @end|ng |rom gm@||@com (Tomas Kalibera)
Date: Fri, 6 Mar 2020 09:40:57 +0100
Subject: [Rd] survival bug? - solved
In-Reply-To: <28fddd$dci1d4@ironport10.mayo.edu>
References: <28fddd$dc0bti@ironport10.mayo.edu>
 <CAD4oTHGguVjTQf4ishooS=T6y0HwLH799gdu7hJavB+Y9BHLgg@mail.gmail.com>
 <F249D41C-E1D0-4403-9175-BAD88A9386C9@R-project.org>
 <28fddd$dci1d4@ironport10.mayo.edu>
Message-ID: <a3dda934-fd30-c133-fd3d-e9392b98880a@gmail.com>

On 3/5/20 5:39 PM, Therneau, Terry M., Ph.D. via R-devel wrote:
>   ?I ended up finding the issue by a focused code review.
>
> Once in the past, I had a version that would fail under one architecture but not another,
> in that case some help from Brian Ripley pointed me to the offending line of C code.
> That line read, but did not write, at an invalid memory location.?? Starting with the
> question of "what C routines have I added or modified most recently" along with where the
> fault appeared to occur in my test suite, I started reading C code and found one.
> Revised code passes tests on the winbuilder site.
>
> For the curious, I had a line asking "is this patient id different than the last patient
> id" in the C routine underneath survcheck(); I'm making sure that patients don't go
> backwards in time. Essentially
>   ?for (i=0; i< n; i) {
>   ? ?? if (id[i] != id[i-1] )? { ...}
>
> It is still a surprise to me that just LOOKING at this out of range element would cause a
> failure,? [i-1] never appears on the left hand side of any expressions in the ... chunk
> above. Nevertheless, it was an error. ? Que sera sera

In principle out of bounds access to an array, even reading, may not 
only return any value that may be there, but cause a memory protection 
failure (the memory there is not accessible) or have some other impact. 
Reads from memory can also have side effects (other than crashing your 
process).

Tomas

>
> A strong thanks to those who gave solid suggestions for bringing up a local copy of Windows.
>
> Terry T
>
>>>> My latest submission of survival3.1-10 to CRAN fails  a check, but only on
>>>> windows, which
>>>> I don't use.
>>>> How do I track this down?
>>>> The test in question works fine on my Linux box.
>>>>
>>>> Terry
>>>>
>>>>
>>>>
>>>>          [[alternative HTML version deleted]]
>>>>
>>>> ______________________________________________
>>>> R-devel at r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>>>
>>> 	[[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> R-devel at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] survival bug? - solved
Tomas Kalibera