From ripley at stats.ox.ac.uk  Thu Oct  8 12:26:31 2009
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Thu, 8 Oct 2009 11:26:31 +0100 (BST)
Subject: [Rd] (PR#13957) Reading clipboard with read.delim("clipboard")
 crash
In-Reply-To: <20090918091015.C9EA3282EF2D@mail.pubhealth.ku.dk>
References: <20090918091015.C9EA3282EF2D@mail.pubhealth.ku.dk>
Message-ID: <alpine.LFD.2.00.0910081110320.23973@auk.stats.ox.ac.uk>

I am having some trouble reproducing this (an example of 3000 rows and 
7 columns worked for me, and one of 18000 rows stresses the window 
manager so it works slowly if at all).

But AFAICS you are trying to give your window manager too much data, 
and the XGetWindowProperty call to determine the size is failing.  R 
had no code to catch that possibility, and now I've added some I can 
no longer provoke a crash: but as expected you get the result

> dat <- read.delim('clipboard')
Error in file(file, "r") : cannot open the connection
In addition: Warning message:
In file(file, "r") : clipboard cannot be opened or contains no text

(sometimes after a wait of more than a minute).

So even if it were somehow possible to pass 1Mb of data via an X11 
clipboard, it looks as if it would be too slow to be useful.

On Fri, 18 Sep 2009, liam.gretton at leicester.ac.uk wrote:

> Full_Name: Liam Gretton
> Version: 2.9.2
> OS: openSUSE 11.1 (x86_64)
> Submission from: (NULL) (143.210.13.77)
>
>
> Reading a large number of rows of delimited data via the clipboard results in a
> segfault or double free error. I've tested copying from various applications,
> but gedit will do.
>
> This problem exists in the openSUSE-supplied 2.8.1, I've just built 2.9.2 to see
> if it's still there, and it is.
>
> I can provide an example delimited file which demonstrates the problem; it
> contains about 18000 rows and 7 columns of data. read.delim("clipboard") tends
> to fail when only reading ~1500 rows, though I haven't been able to reproduce
> the point at which it fails.
>
> Reading exactly the same data from a file using read.csv("file.csv") is
> successful.
>
> Problem reproduced as so:
>
> Data copied to the clipboard in Gnome.
>
>> R
> R version 2.9.2 (2009-08-24)
> [snip]
>
>> data <- read.delim("clipboard")
>
> *** caught segfault ***
> address 0x18, cause 'memory not mapped'
>
> Traceback:
> 1: file(file, "r")
> 2: read.table(file = file, header = header, sep = sep, quote = quote,     dec =
> dec, fill = fill, comment.char = comment.char, ...)
> 3: read.delim("clipboard")
>
> Possible actions:
> 1: abort (with core dump, if enabled)
> 2: normal R exit
> 3: exit R without saving workspace
> 4: exit R saving workspace
>
> On a different (but similar) openSUSE 11.1 system, the command still fails but
> reports:
>
> *** glibc detected *** /usr/local/R-2.9.2/lib64/R/bin/exec/R: double free of
> corruption (!prev): 0x000000000097cb70 ***
>
> Details of R build:
>
> ./configure --prefix=/usr/local/R-2.9.2 --enable-R-shlib --enable-mbcs
> --enable-threads=posix  --with-blas  --with-lapack --with-system-zlib
> --with-system-bzlib --with-system-pcre --with-gnu-ld
>
> No additional packages installed. 'make check' passed.
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] (PR#13957) Reading clipboard with read.delim("clipboard") crash
Prof Brian Ripley