11
$\begingroup$

Bug introduced in 8.0 and persisting through 12.0 or later
CopyToClipboard is new in 8.0.


This is freezing the FrontEnd:

CopyToClipboard@ExampleData[{"Text", "AeneidEnglish"}]

Are there system limits I'm hitting here?

$\endgroup$
2
  • 2
    $\begingroup$ What is funny: a=ExampleData[{"Text", "AeneidEnglish"}]works and if I select the cells content (the whole text of only about 606 KByte) then the whole text can be copied to the Windows or Mac Clipboard and can be pasted again into a new notebook. It seems that the function CopyToClipboard has a problem .. $\endgroup$
    – mrz
    Apr 28 '16 at 20:47
  • 2
    $\begingroup$ I confirm that CopyToClipboard@ExampleData[{"Text", "AeneidEnglish"}] makes FrontEnd not responding and taking 100% time of one virtual CPU core on Windows 7 x64 both with versions 8.0.4 and 10.4.1. With version 8.0.4 it finishes successfully after 2 minutes of work but with version 10.4.1 it seems to go to infinite loop (doesn't finish after 10 minutes of work). So it's a FrontEnd bug and has nothing to do with system limits. $\endgroup$ Apr 29 '16 at 5:27
2
$\begingroup$

(Not a complete analysis of the issue, just a couple of observations.)

[All the timings are obtained with Mathematica 11.1.0 on Windows 7 x64.]

Let us check the timings for copying of the "AeneidEnglish" text. Since it takes a lot of time and potentially can lead to a crash, I collect the timing data in a file:

text = ExampleData[{"Text", "AeneidEnglish"}];
Do[{n, CopyToClipboard[StringTake[text, n]] // AbsoluteTiming // First} >>> 
   timings.txt, {n, 10000, 600000, 10000}];

The collected data is here. Let us plot it:

timings = ReadList["http://pastebin.com/raw/pD4zWabd"];
nlm = NonlinearModelFit[timings, a n^k, {a, {k, 2}}, n];
Show[ListPlot[timings, PlotStyle -> Black], Plot[Normal[nlm], {n, 0, 600000}], 
 AxesLabel -> {"n", "seconds"}, Epilog -> Text[Style[Normal[nlm], 20], {300000, 500}], 
 PlotRangePadding -> None, PlotRangeClipping -> False]

plot

We have got a square-law dependence! But what is so special with this text? Let us collect the timings for a random string consisting of ASCII characters:

asciiString = StringJoin[RandomChoice[CharacterRange[" ", "~"], 600000]];
Do[{n, CopyToClipboard[StringTake[asciiString, n]] // AbsoluteTiming // First} >>> 
   timings2.txt, {n, 10000, 150000, 10000}];

Compare it with the timings for the "AeneidEnglish" text:

timings2 = ReadList["timings2.txt"];
nlm2 = NonlinearModelFit[timings2, a n^k, {a, {k, 2}}, n];
Normal[nlm2]
Show[ListPlot[{timings, timings2}, PlotStyle -> Black], 
 Plot[Evaluate@Normal[{nlm, nlm2}], {n, 0, 600000}], AxesLabel -> {"n", "seconds"}, 
 PlotRange -> {{0, 150000}, {0, 45}}, PlotRangePadding -> None, 
 PlotRangeClipping -> False]    

3.80602*10^-9 n^1.98161

plot

The dependence is still quadratic, but the timings are about 2 times worse!

How can this be explained? I don't know.

$\endgroup$
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.