JDK-4319831 : Large Clipboard contents passed to AWT components should not crash JRE
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1.8
  • Priority: P3
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_95
  • CPU: x86
  • Submitted: 2000-03-08
  • Updated: 2001-05-09
  • Resolved: 2001-05-09
Related Reports
Relates :  
Description

Name: krT82822			Date: 03/08/2000


orig synopsis:  "Too much data from Windows Clipboard crashes JRE"

java version "1.1.8"

Background: It is my impression that a goal of the JVM is that no Java program
should be able to make the JVM crash. Sure, a Java program may stop
running (for example, when the JVM reports an exception and the Java
program doesn't catch it), but the JVM should stay running long enough
to exit nicely (including, releasing system resources). If the JVM
crashes, is doesn't get a chance to exit nicely.

The bug in the JVM that I am reporting to you violates this assumption,
in that there is no way for a programmer to catch this error and prevent
the Java program *and* the JVM from crashing.  Am I wrong in my
assumption about your goals for the JVM?

  To reproduce the problem:
 
 * Open Excel.
 * Use Edit | Fill | Series to put numbers in column 1, rows 1..60,000.
 * Use Edit | Fill | Series to put numbers in column 2, rows 1..60,000.
 * Block columns 1 and 2 and press ^C to put the data on the clipboard.
 * Run a Java program that can grab text data from the clipboard.
 * Grab the text data from the clipboard.
 * JRE crashes and you will get an error message in a small window saying:
 
 "This program has performed an illegal operation and will be shut down.
 If the problem persists, contact the program vendor.
 Details:
 JRE caused a stack fault in module WINAWT.DLL at
 0137:031b0e27."
 
If you work with less data, Java works fine.

If you try to insert this much data in Microsoft Word, it accepts it (not
quickly, but it does it).

If you try to insert this much data into Notepad, it gives you an error message
saying there isn't enough memory, but it doesn't crash.
 
This problem has existed for several versions of jre and java (1.1.6,
1.1.7, 1.1.8), probably all previous, and probably all subsequent. It also
occurs on Win98.

I understand that the Windows clipboard has size limits. However, the crashing
of JRE seems to be a problem in the AWT libraries. Even if it is a Windows
problem (which I don't think it is), JRE should catch the error and throw an
exception. JRE should not crash.
 
The limit of the win9x clipboard seems to be around 512,000 characters,
which is considerably larger than the capacity of an AWT TextArea, 
for example.  No matter what the limit of the component accepting
the clipboard data, the JRE shouldn't crash.

This is a severe problem since there seems to be no way for me to write a
program to trap the error (e.g., try catch) yet a user can easily crash jre when
transferring lots of data.
(Review ID: 102212) 
======================================================================

Comments
WORK AROUND Name: krT82822 Date: 03/08/2000 None. 8 Mar 2000 evall127@eng -- when deciding whether to accept paste (or drop), check incoming clipboard contents size, and either refuse or limit amount accepted, based on known limitations of the AWT component(s) in question. ======================================================================
11-06-2004

EVALUATION On 98, this is reproducible in 1.1.8, 1.2.2, and 1.3rc1. The crash is caused by a stack overflow. In the latest merlin build, the crash is gone. However, the call to the Win32 function GetClipboradData hangs indefinitely on large inputs. On NT, this is reproducible in 1.1.8. In 1.2.2 and 1.3rc1, we throw an OutOfMemoryError. In the latest merlin build, the paste fails silently. david.mendenhall@eng 2000-03-09 According to david.mendenhall@eng the paste hangs on windows95. We are not sure if this is a problem with Java or a problem with windows. We should resolve this for Merlin. Thought: does this happen on Solaris? eric.hawkes@eng 2000-03-09 Name: biR10147 Date: 05/07/2001 Current workspace and the latest promoted builds don't crash when reading large amounts of text from system clipboard. I couldn't reproduce the hang either: application either threw OutOfMemoryError or succeed on both Win98 and WinNT. ###@###.### ====================================================================== Closing bug as Not Reproducible. This bug has been fixed for merlin. The fix will appear in either beta or beta-refresh. david.mendenhall@east 2001-05-08
08-05-2001