[Rd] (PR#11281) Bug in R 2.7 for over long lines

Martin Maechler maechler at stat.math.ethz.ch
Tue May 13 09:50:01 CEST 2008


>>>>> "SS" == Soeren Sonnenburg <r-ml at nn7.de>
>>>>>     on Tue, 13 May 2008 08:17:23 +0200 writes:

    SS> On Mon, 2008-05-12 at 08:39 -0400, Duncan Murdoch wrote:
    >> On 5/10/2008 5:20 PM, bugreports at nn7.de wrote: > On Sat,
    >> 2008-05-10 at 11:19 +0100, Prof Brian Ripley wrote: >>
    >> You will see the current code is different, and your
    >> 'fix' is not needed=20 >> nor applies in R-devel.
    >> > 
    >> > would be nice...
    >> > 
    >> >> You failed to provide an example to reproduce the
    >> alleged bug, but the=20
    >> > 
    >> > well the bug was obvious, I told that I can trigger it
    >> and that the > proposed fix fixed it - no need to provide
    >> an example.
    >> 
    >> But it would be helpful to provide an example, so that we
    >> can test the fix.  As Brian told you, your fix was no
    >> good: it was not against the current code.

    SS> Well it was when I posted it 4 days after R 2.7.0 was
    SS> released.

    SS> And the bug was very obvious, I mean look at this
    SS> (quoting from my original report):

     SS> char *LongLine = (char *) malloc(nc);
     SS> ...
     SS> LongLine[nc] = '\0';

     SS> note that LongLine is only nc chars long, so the LongLine[nc]='\0' might
     SS> be an out of bounds write. the fix would be to do 
     SS> char *LongLine = (char *) malloc(nc+1);

Yes, you are right about this (first part of your report).

    SS> Anyway an example that will crash R 2.7.0 is here
    SS> http://nn7.de/debugging/Features.R .
 
    >> >> issue does seem to be using lines beyond the
    >> documented line length.
    >> > 
    >> > exactly. one can crash R with too long lines.
    >> 
    >> Then the bug is also in your code, for sending lines that
    >> are too long.  R shouldn't crash on user error, but
    >> "don't do that" is an appropriate response.

    SS> I would just like to see this bug in R fixed.

    >> >> So it would have only affected people who did that
    >> ....
    >> > 
    >> > or use auto-generated code like e.g. swig produces.
    >> 
    >> Then swig should be modified to produce valid code.

    SS> Sure. That's what I am trying to achieve.

    SS> [...]
    >> > I don't intend to play with devel versions of R, I was
    >> just trying to > get swig for R2.7 to work. Sorry that it
    >> triggered a bug in R. =EF=BB=BFI w= > ill > try R2.7.1
    >> when it is released and report back.
    >> 
    >> If you aren't interested in being helpful by testing
    >> fixes for your code, then I doubt if any of us are going
    >> to go out of our way to help you with your errors.

    SS> I still don't understand what I could have possibly
    SS> done wrong in my initial post
    SS> (http://article.gmane.org/gmane.comp.lang.r.devel/16243/)
    SS> to cause this meta-discussion.

I think it was partly misunderstanding on both sides.

The bug *was* indeed fixed only a couple of hours after your report :

 >> r45496 | ... | 2008-04-25 09:37:53 +0200 (Fri, 25 Apr 2008) |
 >> 
 >> change long-standing out-by-one error for invalid input

I agree it would have been kind if we had thanked you
and had told you that the bug actually had been fixed.
Sometimes this if forgotten because of busy "schedules" ...
So let me give you late 
   ** Thank you very much !! ** 
for the original bug report.

Martin Maechler, ETH Zurich

    SS> But to put things in the right light. There is no bug in
    SS> my code (this time). But in R. And I did not ask for
    SS> help - to the contrary: I've pointed out a trivial to
    SS> fix bug in R 2.7.0 and showed how it could be fixed.

    SS> The problem is that I am not really an R user, but just
    SS> wanted to support the R community by porting shogun to R
    SS> in the hope that it may be useful for some. To achieve
    SS> this I am fixing bugs in the R swig interface generator
    SS> and now also R. So the detour I am taking here is
    SS> massive and I have not received any help (except from
    SS> Dirk so far).

    SS> So if possible lets stay focused on the bug: Dirk helped
    SS> me to get the R from svn-trunk (it says R 2.8 at
    SS> startup) to compile and voila, sourcing the code from
    SS> above does not generate any crashes anymore. So the
    SS> rewrite of gram.c fixes it I guess.

    SS> Soeren



More information about the R-devel mailing list