JDK-4737496 : JPEGImageWriter causes FatalError(1.4) & warning msgs(1.4.1-rc) with -Xcheck:jni
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.imageio
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2002-08-27
  • Updated: 2003-08-26
  • Resolved: 2003-08-26
Related Reports
Duplicate :  
Description

Name: rmT116609			Date: 08/27/2002


FULL PRODUCT VERSION :
java version "1.4.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)


also


java version "1.4.1-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-rc-b19)
Java HotSpot(TM) Client VM (build 1.4.1-rc-b19, mixed mode)

FULL OPERATING SYSTEM VERSION :

rpm -query glibc returns glibc-2.2.4-13

uname -a returns

Linux lnx37 2.4.7-10smp #1 SMP Thu Sep 6 17:09:31 EDT
2001 i686 unknown

cat /etc/redhat-release returns

Red Hat Linux release 7.2 (Enigma)

Additional Operating System's: Windows 2000

A DESCRIPTION OF THE PROBLEM :
I'm trying to debug some code that uses JNI, and my initial course of action was to add -Xcheck:jni to the command line.

Under runtime version 1.4.0_01 this produced the following stack trace:

FATAL ERROR in native method: Calling other JNI
functions in the scope of
Get/ReleasePrimitiveArrayCritical or
Get/ReleaseStringCritical
        at
com.sun.imageio.plugins.jpeg.JPEGImageWriter.writeImage(Native
Method)
        at
com.sun.imageio.plugins.jpeg.JPEGImageWriter.write(JPEGImageWriter.java:926)
        at
javax.imageio.ImageWriter.write(ImageWriter.java:591)
        at
javax.imageio.ImageIO.write(ImageIO.java:1365)
        at
javax.imageio.ImageIO.write(ImageIO.java:1403)

<remainder of stack trace removed>


Under 1.4.1-rc, the error still happens, but instead of a stack trace I receive the following string:

Warning: Calling other JNI functions in the scope of Get/ReleasePrimitiveArrayCritical or
Get/ReleaseStringCritical


I am assuming that this is still the same error, because I do not call any of the above mentioned critical methods in my own native code.

It would seem that the error reports from JRE 1.4.0 are more useful to me since they include a stack trace. However, since the JPEGWriter class is causing a fatal error, I cannot fully debug the behaviour of my code with the Xcheck:jni switch.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile source code given (JavaTest class)
2. Run with command 'java -Xcheck:jni JavaTest"

EXPECTED VERSUS ACTUAL BEHAVIOR :

I would expect to see the output "success" before the program completes.

However, under JRE 1.4.0_01-b03 I receive the following output:

$ java -Xcheck:jni JavaTest
FATAL ERROR in native method: Calling other JNI
functions in the scope of
Get/ReleasePrimitiveArrayCritical or
Get/ReleaseStringCritical
        at
com.sun.imageio.plugins.jpeg.JPEGImageWriter.writeImage(Native
Method)
        at
com.sun.imageio.plugins.jpeg.JPEGImageWriter.write(JPEGImageWriter.java:926)
        at
javax.imageio.ImageWriter.write(ImageWriter.java:591)
        at
javax.imageio.ImageIO.write(ImageIO.java:1365)
        at
javax.imageio.ImageIO.write(ImageIO.java:1403)
        at JavaTest.main(JavaTest.java:22)

ERROR MESSAGES/STACK TRACES THAT OCCUR :
FATAL ERROR in native method: Calling other JNI functions in the scope of
Get/ReleasePrimitiveArrayCritical or Get/ReleaseStringCritical
        at com.sun.imageio.plugins.jpeg.JPEGImageWriter.writeImage(Native
Method)
        at
com.sun.imageio.plugins.jpeg.JPEGImageWriter.write(JPEGImageWriter.java:926)
        at javax.imageio.ImageWriter.write(ImageWriter.java:591)
        at javax.imageio.ImageIO.write(ImageIO.java:1365)
        at javax.imageio.ImageIO.write(ImageIO.java:1403)
        at JavaTest.main(JavaTest.java:22)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------

import java.awt.image.BufferedImage;

import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

class JavaTest
{
	public static void main(String [] args)
	{
		// create a new image
		BufferedImage img = new BufferedImage(10, 10,                                               BufferedImage.TYPE_INT_ARGB);
		
		// create a file object to write to
		File f = new File("output.jpeg");
		
		// write the image to a jpeg files
		try
		{
			ImageIO.write(img, "jpeg", f);
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
		
		// we'll never get here.
		System.out.println("success");
		
		return;
	}
}
---------- END SOURCE ----------

CUSTOMER WORKAROUND :
The only workaround is to remove -Xcheck:jni from the command line, but that defeats the purpose.
(Review ID: 163655) 
======================================================================

Comments
EVALUATION This is a duplicate of 4528643, which contains more detailed information and includes a suggested fix. ###@###.### 2003-08-26
26-08-2003