Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@apache.org Received: (qmail 77255 invoked from network); 23 Feb 2002 21:31:49 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 23 Feb 2002 21:31:49 -0000 Received: (qmail 10405 invoked by uid 97); 23 Feb 2002 21:31:04 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-user@jakarta.apache.org Received: (qmail 10313 invoked by uid 97); 23 Feb 2002 21:31:03 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Users List" Reply-To: "Tomcat Users List" Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 10298 invoked from network); 23 Feb 2002 21:31:03 -0000 From: "Shawn Church" To: "Tomcat Users List" Subject: RE: Help Preventing VM & Tomcat Crash Date: Sat, 23 Feb 2002 15:31:35 -0600 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) In-Reply-To: <5.1.0.14.2.20020223152636.02dda428@pop-server.cox.rr.com> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N So much for that theory. However, your guess is pretty close. I found something which you might find interesting. This is a known bug, which you can check out here: http://developer.java.sun.com/developer/bugParade/bugs/4502892.html The problem occurs when the socket is prematurely closed. The workaround is to buffer the output via ByteArrayOutputStream, isolating the native method from stream disconnections. The evaluation of the bug I will include here for convenience: *** The JPEG library is not MT-safe. In particular, there is a definition of a global variable "struct error_mgr ek_err" which is used by all threads for error handling -- including a setjmp buffer. Consequently, when an error does occur while more than one thread is executing in the native library, it is common for that thread to longjmp to another thread's state. It then uses the wrong JNIEnv pointer and trashes the VM. xxxxx@xxxxx 2001-10-09 This bug has indeed been fixed in merlin-rc1, but its associated regression test (JPEGMultithread.java) is confusing and potentially misleading. This is addressed by another bug (4546112 - Reg-test JPEGMultithread.java Failing). The regression test currently throws exceptions endlessly if bug 4502892 is not present, and hangs or crashes the VM if bug 4502892 is present. This is bad behavior for a regression test, so it will be updated in accordance with 4546112. xxxxx@xxxxx 2001-12-19 *** Hope this helps more, Shawn -----Original Message----- From: Kennedy Clark [mailto:kclark@iname.com] Sent: Saturday, February 23, 2002 2:32 PM To: Tomcat Users List Subject: RE: Help Preventing VM & Tomcat Crash Hi Shawn, Many thanks for the note & the suggestion! I am using MySQL as my Db and MM.MySQL is my driver (mm.mysql-2.0.11-bin.jar). Given that this is a Type 4 driver, I don't think I should be getting a native code crash involving database access, right? I could be missing something, but it seems that the sun.awt.image.codec.JPEGImageEncoderImpl.writeJPEGStream() method (which is native code) is trying to write to my output stream and running into trouble. I assume this is because the user has clicked on an image serving as a link to another web page and now Tomcat is off trying to handle the new page. My best guess is that in the process of doing so, the output streams used by writeJPEGStream() are being torn down, but the native code doesn't know this and it's causing the VM to puke. Does anyone think my logic makes sense? Better yet, does anyone know a way to prevent it? :-) Regards, Kennedy At 09:02 AM 2/23/2002 -0600, Shawn Church wrote: >Looks like you are using the JDBC-ODBC bridge (maybe to an MS Access or MS >SQL Server database?), which is not thread-safe and is not intended for use >in production environments. My guess is that one thread (the current thread >servicing the Thumbnail servlet) has a db connection open, and the next >request (the user clicking the thumbnail) opens another db connection. This >guess is based on these lines in your exception: > >An unexpected exception has been detected in native code outside the VM. >Unexpected Signal : unknown exception code occurred at PC=0x77fb16cc >Function name=RtlTraceDatabaseEnumerate >Library=C:\WINNT\System32\ntdll.dll > >If this is the case, try finding a pure Java (type 4) JDBC driver for your >database. > >Shawn > > >-----Original Message----- >From: Kennedy Clark [mailto:kclark@iname.com] >Sent: Saturday, February 23, 2002 5:36 AM >To: tomcat-user@jakarta.apache.org >Subject: Help Preventing VM & Tomcat Crash > > >I'm working on a servlet that shrinks JPEG photos on the fly to create >thumbnails. When the user selects the thumbnail page, a JSP generates HTML >that results in many calls to the thumbnail servlet. If the user is >patient and waits for all of the thumbnails to load, everything works great >-- they can click on a thumbnail to see the full-size version of that >JPEG. However, if the use clicks on a photo while they are still loading, >I get the exception dump and crash shown at the bottom. Any help greatly >appreciated! Regards, Kennedy > >Here is my thumbnail servlet: >/* > * Note: JPEG manipulation code comes from Sun: > * http://developer.java.sun.com/developer/TechTips/1999/tt1021.html#tip1 > */ >package gallery.servlet; > >import java.io.*; >import java.text.*; >import java.util.*; >import javax.servlet.*; >import javax.servlet.http.*; >import java.awt.Image; >import java.awt.Graphics2D; >import java.awt.geom.AffineTransform; >import java.awt.image.BufferedImage; >import javax.swing.ImageIcon; >import com.sun.image.codec.jpeg.JPEGCodec; >import com.sun.image.codec.jpeg.JPEGImageEncoder; > > >/** > * Return a thumbnail of the image specified in the name parameter > */ > >public class Thumbnail extends HttpServlet { > > > public void doGet(HttpServletRequest request, > HttpServletResponse response) > throws IOException, ServletException > { > response.setContentType("image/jpeg"); > File f = new File(request.getParameter("name")); > if (!f.exists()) > return; > OutputStream os = response.getOutputStream(); > createThumbnail(request.getParameter("name"), os, 150); > } > > /** > * Reads an image in a file and creates a thumbnail to the output >stream > * > * @param orig The name of image file. > * @param thumb The name of thumbnail file. > * Will be created if necessary. > * @param maxDim The width and height of the thumbnail must > * be maxDim pixels or less. > */ > public static void createThumbnail(String orig, OutputStream os, int >maxDim) { > try { > // Get the image from a file. > Image inImage = new ImageIcon(orig).getImage(); > > // Determine the scale. > double scale = (double)maxDim/(double)inImage.getHeight(null); > if (inImage.getWidth(null) > inImage.getHeight(null)) { > scale = (double)maxDim/(double)inImage.getWidth(null); > } > > // Determine size of new image. > // One of them should equal maxDim. > int scaledW = (int)(scale*inImage.getWidth(null)); > int scaledH = (int)(scale*inImage.getHeight(null)); > > // Create an image buffer in which to paint on. > BufferedImage outImage = > new BufferedImage(scaledW, scaledH, >BufferedImage.TYPE_INT_RGB); > > // Set the scale. > AffineTransform tx = new AffineTransform(); > > // If the image is smaller than > //the desired image size, > // don't bother scaling. > if (scale < 1.0d) { > tx.scale(scale, scale); > } > > // Paint image. > Graphics2D g2d = outImage.createGraphics(); > g2d.drawImage(inImage, tx, null); > g2d.dispose(); > > // JPEG-encode the image and write to file. > //OutputStream os = new FileOutputStream(thumb); > JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(os); > encoder.encode(outImage); > //os.close(); > } catch (IOException e) { > e.printStackTrace(); > } > } >} > > > >And here is the exception/crash: >java.io.IOException: reading encoded JPEG Stream > at sun.awt.image.codec.JPEGImageEncoderImpl.writeJPEGStream(Native >Method) > at >sun.awt.image.codec.JPEGImageEncoderImpl.encode(JPEGImageEncoderImpl.java:4 7 >5) > > at >sun.awt.image.codec.JPEGImageEncoderImpl.encode(JPEGImageEncoderImpl.java:2 3 >1) > at gallery.servlet.Thumbnail.createThumbnail(Thumbnail.java:85) > at gallery.servlet.Thumbnail.doGet(Thumbnail.java:35) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) > at >org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicatio n >FilterChain.java:247) > at >org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterC h >ain.java:193) > at >org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.j a >va:243) > at >org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java: 5 >66) > at >org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) > at >org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) > at >org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.j a >va:201) > at >org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java: 5 >66) > at >org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBas e >.java:518) > at >org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java: 5 >64) > at >org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) > at >org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) > at >org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344) > at >org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:16 4 >) > at >org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java: 5 >66) > at >org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve . >java:170) > at >org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java: 5 >64) > at >org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:17 0 >) > at >org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java: 5 >64) > at >org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462) > at >org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java: 5 >64) > at >org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:392 ) > at >org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java: 5 >64) > at >org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) > at >org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) > at >org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.jav a >:163) > at >org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java: 5 >66) > at >org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) > at >org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) > at >org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java : >1011) > at >org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:110 6 >) > at java.lang.Thread.run(Thread.java:484) >An unexpected exception has been detected in native code outside the VM. >Unexpected Signal : unknown exception code occurred at PC=0x77fb16cc >Function name=RtlTraceDatabaseEnumerate >Library=C:\WINNT\System32\ntdll.dll > >Current Java thread: > at sun.awt.image.codec.JPEGImageEncoderImpl.writeJPEGStream(Native >Method) > at >sun.awt.image.codec.JPEGImageEncoderImpl.encode(JPEGImageEncoderImpl.java:4 7 >5) > at >sun.awt.image.codec.JPEGImageEncoderImpl.encode(JPEGImageEncoderImpl.java:2 3 >1) > at gallery.servlet.Thumbnail.createThumbnail(Thumbnail.java:85) > at gallery.servlet.Thumbnail.doGet(Thumbnail.java:35) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) > at >org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicatio n >FilterChain.java:247) > at >org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterC h >ain.java:193) > at >org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.j a >va:243) > at >org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java: 5 >66) > at >org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) > at >org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) > at >org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.j a >va:201) > at >org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java: 5 >66) > at >org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBas e >.java:518) > at >org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java: 5 >64) > at >org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) > at >org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) > at >org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344) > at >org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:16 4 >) > at >org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java: 5 >66) > at >org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve . >java:170) > at >org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java: 5 >64) > at >org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:17 0 >) > at >org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java: 5 >64) > at >org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462) > at >org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java: 5 >64) > at >org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:392 ) > at >org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java: 5 >64) > at >org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) > at >org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) > at >org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.jav a >:163) > at >org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java: 5 >66) > at >org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) > at >org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) > at >org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java : >1011) > at >org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:110 6 >) > at java.lang.Thread.run(Thread.java:484) > >Dynamic libraries: >0x00400000 - 0x00405000 D:\JBuilder6\jdk1.3.1\bin\java.exe >0x77F80000 - 0x77FFB000 C:\WINNT\System32\ntdll.dll >0x77DB0000 - 0x77E0B000 C:\WINNT\system32\ADVAPI32.dll >0x77E80000 - 0x77F35000 C:\WINNT\system32\KERNEL32.DLL >0x77D40000 - 0x77DAC000 C:\WINNT\system32\RPCRT4.DLL >0x78000000 - 0x78046000 C:\WINNT\system32\MSVCRT.dll >0x6D420000 - 0x6D4EE000 >D:\JBuilder6\jdk1.3.1\jre\bin\hotspot\jvm.dll >0x77E10000 - 0x77E74000 C:\WINNT\system32\USER32.dll >0x77F40000 - 0x77F7C000 C:\WINNT\system32\GDI32.DLL >0x77570000 - 0x775A0000 C:\WINNT\System32\WINMM.dll >0x681A0000 - 0x681A7000 C:\WINNT\System32\serwvdrv.dll >0x66740000 - 0x66747000 C:\WINNT\System32\umdmxfrm.dll >0x6D220000 - 0x6D227000 D:\JBuilder6\jdk1.3.1\jre\bin\hpi.dll >0x6D3B0000 - 0x6D3BD000 D:\JBuilder6\jdk1.3.1\jre\bin\verify.dll >0x6D250000 - 0x6D266000 D:\JBuilder6\jdk1.3.1\jre\bin\java.dll >0x6D3C0000 - 0x6D3CD000 D:\JBuilder6\jdk1.3.1\jre\bin\zip.dll >0x6D340000 - 0x6D348000 D:\JBuilder6\jdk1.3.1\jre\bin\net.dll >0x75050000 - 0x75058000 C:\WINNT\System32\WSOCK32.dll >0x75030000 - 0x75043000 C:\WINNT\System32\WS2_32.DLL >0x75020000 - 0x75028000 C:\WINNT\System32\WS2HELP.DLL >0x74FD0000 - 0x74FEF000 C:\WINNT\system32\msafd.dll >0x75010000 - 0x75017000 C:\WINNT\System32\wshtcpip.dll >0x785C0000 - 0x785CC000 C:\WINNT\System32\rnr20.dll >0x77980000 - 0x779A4000 C:\WINNT\System32\DNSAPI.DLL >0x77340000 - 0x77353000 C:\WINNT\System32\iphlpapi.dll >0x77520000 - 0x77525000 C:\WINNT\System32\ICMP.DLL >0x77320000 - 0x77337000 C:\WINNT\System32\MPRAPI.DLL >0x75150000 - 0x75160000 C:\WINNT\System32\SAMLIB.DLL >0x75170000 - 0x751BF000 C:\WINNT\System32\NETAPI32.DLL >0x77BE0000 - 0x77BEF000 C:\WINNT\System32\SECUR32.DLL >0x751C0000 - 0x751C6000 C:\WINNT\System32\NETRAP.DLL >0x77950000 - 0x77979000 C:\WINNT\system32\WLDAP32.DLL >0x77A50000 - 0x77B3A000 C:\WINNT\system32\OLE32.DLL >0x779B0000 - 0x77A4B000 C:\WINNT\system32\OLEAUT32.DLL >0x773B0000 - 0x773DE000 C:\WINNT\System32\ACTIVEDS.DLL >0x77380000 - 0x773A2000 C:\WINNT\System32\ADSLDPC.DLL >0x77830000 - 0x7783E000 C:\WINNT\System32\RTUTILS.DLL >0x77880000 - 0x7790D000 C:\WINNT\System32\SETUPAPI.DLL >0x77C10000 - 0x77C6D000 C:\WINNT\System32\USERENV.DLL >0x774E0000 - 0x77512000 C:\WINNT\System32\RASAPI32.DLL >0x774C0000 - 0x774D1000 C:\WINNT\System32\RASMAN.DLL >0x77530000 - 0x77552000 C:\WINNT\system32\TAPI32.DLL >0x716F0000 - 0x7177A000 C:\WINNT\system32\COMCTL32.DLL >0x70BD0000 - 0x70C1C000 C:\WINNT\system32\SHLWAPI.DLL >0x77360000 - 0x77379000 C:\WINNT\System32\DHCPCSVC.DLL >0x775A0000 - 0x77625000 C:\WINNT\System32\CLBCATQ.DLL >0x777E0000 - 0x777E8000 C:\WINNT\System32\winrnr.dll >0x777F0000 - 0x777F5000 C:\WINNT\System32\rasadhlp.dll >0x6D020000 - 0x6D128000 D:\JBuilder6\jdk1.3.1\jre\bin\awt.dll >0x77800000 - 0x7781D000 C:\WINNT\System32\WINSPOOL.DRV >0x75E60000 - 0x75E7A000 C:\WINNT\System32\IMM32.dll >0x6D1E0000 - 0x6D21B000 >D:\JBuilder6\jdk1.3.1\jre\bin\fontmanager.dll >0x51000000 - 0x51044000 C:\WINNT\System32\DDRAW.dll >0x728A0000 - 0x728A6000 C:\WINNT\System32\DCIMAN32.dll >0x69000000 - 0x6910E000 C:\WINNT\System32\ATIO2KAB.dll >0x6D2C0000 - 0x6D2DB000 D:\JBuilder6\jdk1.3.1\jre\bin\jpeg.dll >0x77920000 - 0x77943000 C:\WINNT\system32\imagehlp.dll >0x72A00000 - 0x72A2D000 C:\WINNT\system32\DBGHELP.dll >0x0C680000 - 0x0C68B000 C:\WINNT\System32\PSAPI.DLL > >Local Time = Fri Feb 22 22:39:59 2002 >Elapsed Time = 82 ># ># The exception above was detected in native code outside the VM ># ># Java VM: Java HotSpot(TM) Client VM (1.3.1_01 mixed mode) ># ># An error report file has been saved as hs_err_pid456.log. ># Please refer to the file for further information. ># >E:\java\tomcat4\bin> > > >-- >To unsubscribe: >For additional commands: >Troubles with the list: > > >-- >To unsubscribe: >For additional commands: >Troubles with the list: -- To unsubscribe: For additional commands: Troubles with the list: -- To unsubscribe: For additional commands: Troubles with the list: