JavaXPCOM JVM Crash evaluating XPath expression



Core Graveyard
Java to XPCOM Bridge
12 years ago
3 years ago


(Reporter: Micael Gallego, Assigned: jhp (no longer active))


Windows XP

Firefox Tracking Flags

(Not tracked)



(1 attachment)



12 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv: Gecko/20060426 Firefox/
Build Identifier: XulRunner

The problem is that JVM crash while evaluation of XPath expression is made in a loaded page. Some times, the JVM crash quickly and other times the JVM crash later a few evaluations... but always crash.

Reproducible: Always

Steps to Reproduce:
I develop a test code. This code load a html page stored in harddisk
and evaluate XPath expression in loaded page. I have test with diferent
html pages, and always JVM crash.

The test code is the follows:

--------------- JAVA CODE BEGINS HERE ---------------

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.MozillaBrowser;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.mozilla.xpcom.Mozilla;
import org.mozilla.xpcom.nsIComponentManager;
import org.mozilla.xpcom.nsIDOMElement;
import org.mozilla.xpcom.nsIDOMHTMLDocument;
import org.mozilla.xpcom.nsIDOMNode;
import org.mozilla.xpcom.nsIDOMXPathEvaluator;
import org.mozilla.xpcom.nsIDOMXPathNSResolver;
import org.mozilla.xpcom.nsIDOMXPathResult;
import org.mozilla.xpcom.nsIRequest;
import org.mozilla.xpcom.nsISupports;
import org.mozilla.xpcom.nsIWebProgress;
import org.mozilla.xpcom.nsIWebProgressListener;

public class XPathJVMCrash {

       protected Display display;

       //MozillaBrowser as found in
       protected MozillaBrowser browser;

       //Field used to count start document events
       private int numStart;

       //Latch used to wait until loading is complete
       private CountDownLatch waitLoadLatch;

       //XPCOM XPath evaluator
       private nsIDOMXPathEvaluator xpathEval;

       public static void main(String[] args) {
               new XPathJVMCrash().test();

       public XPathJVMCrash() {


               Mozilla moz = Mozilla.getInstance();
               nsIComponentManager componentManager = moz.getComponentManager();
";1"; //$NON-NLS-1$
               xpathEval = (nsIDOMXPathEvaluator) componentManager
                                               null, nsIDOMXPathEvaluator.NS_IDOMXPATHEVALUATOR_IID);


       private void initBrowser() {

               final CountDownLatch initLatch = new CountDownLatch(1);
               new Thread("SWT-Event-Thread") {
                       public void run() {
                               display = new Display();
                               final Shell shell = new Shell(display);
                               shell.setLayout(new FillLayout());
                               browser = new MozillaBrowser(shell,SWT.NONE){
                                       //Override this method to wait until loading is complete
                                       public void onStateChange(nsIWebProgress aWebProgress, nsIRequest
aRequest, long aStateFlags, long aStatus) {
                                               super.onStateChange(aWebProgress, aRequest, aStateFlags,
                                               testOnStateChange(aWebProgress, aRequest, aStateFlags, aStatus);
                               while (!shell.isDisposed()) {
                                       if (!display.readAndDispatch())

               try {
               } catch (InterruptedException e) {
                       throw new Error(e);


       private void testOnStateChange(nsIWebProgress webProgress, nsIRequest
request, long aStateFlags, long status) {
               boolean isDocument = (aStateFlags &
nsIWebProgressListener.STATE_IS_DOCUMENT) != 0;
               boolean start = (aStateFlags & nsIWebProgressListener.STATE_START) !=
               boolean stop = (aStateFlags & nsIWebProgressListener.STATE_STOP) !=

               if (isDocument) {
                       if (start) {
                       } else if (stop) {
                               if (numStart == 0) {

       private void test() {

               for(int i=0; i<100; i++){

                       System.out.println("Load "+i);

                       waitLoadLatch = new CountDownLatch(1);
                       display.syncExec(new Runnable(){
                               public void run() {
                       try {
                       } catch (InterruptedException e) {

                       for(int j=0; j<100; j++){
                               for(nsIDOMNode node: xpathNodes("//*[@class='l']",
                                       nsIDOMElement element = (nsIDOMElement)
                                       String text = element.getFirstChild().getNodeValue();


       public List<nsIDOMNode> xpathNodes(String xpath, nsIDOMNode context) {

               nsIDOMHTMLDocument document = browser.getDocument();

               nsIDOMXPathNSResolver res = xpathEval.createNSResolver(document);
               nsISupports obj = xpathEval.evaluate(xpath, context, res,
                               nsIDOMXPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);

               nsIDOMXPathResult result = (nsIDOMXPathResult) obj

               List<nsIDOMNode> rNodes = new ArrayList<nsIDOMNode>();

               for(int i=0; i<result.getSnapshotLength(); i++){

               return rNodes;


--------------- JAVA CODE ENDS HERE ---------------

I test previous code with some html pages. A page with crash is a google results page.
Actual Results:  
Java Virtual Machine Crash

Expected Results:  
Normal behaviour, no Java Virtual Machine Crash

A report of JVM crash is:

# An unexpected error has been detected by HotSpot Virtual Machine:
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0b2d5940, pid=2300, tid=868
# Java VM: Java HotSpot(TM) Client VM (1.5.0_06-b05 mixed mode)
# Problematic frame:
# C  0x0b2d5940

---------------  T H R E A D  ---------------

Current thread (0x003a5fd0):  JavaThread "main" [_thread_in_native, id=868]

siginfo: ExceptionCode=0xc0000005, writing address 0xe868bb48

EAX=0x0b38b020, EBX=0x003a6090, ECX=0x0b38b010, EDX=0x0006f954
ESP=0x0006f8c0, EBP=0x0006f98c, ESI=0x0b38f018, EDI=0x0b25a660
EIP=0x0b2d5940, EFLAGS=0x00010246

Top of Stack: (sp=0x0006f8c0)
0x0006f8c0:   60432445 0b38b020 0ad7d408 0006f954
0x0006f8d0:   06d5f7b0 02ad37c8 003a5fd0 00000000
0x0006f8e0:   0b3af000 0b3044e0 00000009 00060060
0x0006f8f0:   00000000 003a6400 0b38d310 00000000
0x0006f900:   00000000 0006f920 601512d0 003a6090
0x0006f910:   0006f93c 0106f950 0106f94c 00000000
0x0006f920:   0006f940 00b7502e 003a6090 a6cf907c
0x0006f930:   11d215b3 80002e93 32dd8a5f 0b3a6c50 

Instructions: (pc=0x0b2d5940)
0x0b2d5930:   8a b8 b6 fc 00 00 00 00 02 00 04 00 75 01 08 03
0x0b2d5940:   10 b1 38 0b 30 dd da 0a 02 00 02 00 7b 01 08 03 

Stack: [0x00030000,0x00070000),  sp=0x0006f8c0,  free space=254k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  0x0b2d5940
C  [javaxpcomglue.dll+0x12d0]
J  org.mozilla.xpcom.internal.XPCOMJavaProxy.callXPCOMMethod(Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;
J  org.mozilla.xpcom.internal.XPCOMJavaProxy.invoke(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;
J  $Proxy19.queryInterface(Ljava/lang/String;)Lorg/mozilla/xpcom/nsISupports;
j  XPathJVMCrash.test()V+119
j  XPathJVMCrash.main([Ljava/lang/String;)V+7
v  ~StubRoutines::call_stub
V  [jvm.dll+0x845a9]
V  [jvm.dll+0xd9317]
V  [jvm.dll+0x8447a]
V  [jvm.dll+0x8b44a]
C  [javaw.exe+0x14c5]
C  [javaw.exe+0x3151]
C  [kernel32.dll+0x16d4f]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J  org.mozilla.xpcom.internal.XPCOMJavaProxy.callXPCOMMethod(Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object;
J  org.mozilla.xpcom.internal.XPCOMJavaProxy.invoke(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;
J  $Proxy19.queryInterface(Ljava/lang/String;)Lorg/mozilla/xpcom/nsISupports;
j  XPathJVMCrash.test()V+119
j  XPathJVMCrash.main([Ljava/lang/String;)V+7
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x0acefd20 JavaThread "SWT-Event-Thread" [_thread_in_native, id=2280]
  0x00a8bef8 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=2988]
  0x00a8abf8 JavaThread "CompilerThread0" daemon [_thread_blocked, id=3884]
  0x00a89e48 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=3604]
  0x00a80e98 JavaThread "Finalizer" daemon [_thread_blocked, id=3796]
  0x00a7fa00 JavaThread "Reference Handler" daemon [_thread_blocked, id=2648]
=>0x003a5fd0 JavaThread "main" [_thread_in_native, id=868]

Other Threads:
  0x00a7b860 VMThread [id=3000]
  0x00a8d208 WatcherThread [id=3948]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

 def new generation   total 576K, used 48K [0x02ad0000, 0x02b70000, 0x02fb0000)
  eden space 512K,   3% used [0x02ad0000, 0x02ad4360, 0x02b50000)
  from space 64K,  49% used [0x02b50000, 0x02b57de0, 0x02b60000)
  to   space 64K,   0% used [0x02b60000, 0x02b60000, 0x02b70000)
 tenured generation   total 1408K, used 338K [0x02fb0000, 0x03110000, 0x06ad0000)
   the space 1408K,  24% used [0x02fb0000, 0x03004958, 0x03004a00, 0x03110000)
 compacting perm gen  total 8192K, used 3156K [0x06ad0000, 0x072d0000, 0x0aad0000)
   the space 8192K,  38% used [0x06ad0000, 0x06de5060, 0x06de5200, 0x072d0000)
No shared spaces configured.

Dynamic libraries:
0x00400000 - 0x0040c000 	O:\prog_instalados\jre1.5.0_06\bin\javaw.exe
0x7c910000 - 0x7c9c6000 	C:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c901000 	C:\WINDOWS\system32\kernel32.dll
0x77da0000 - 0x77e4c000 	C:\WINDOWS\system32\ADVAPI32.dll
0x77e50000 - 0x77ee1000 	C:\WINDOWS\system32\RPCRT4.dll
0x77d10000 - 0x77da0000 	C:\WINDOWS\system32\USER32.dll
0x77ef0000 - 0x77f37000 	C:\WINDOWS\system32\GDI32.dll
0x77be0000 - 0x77c38000 	C:\WINDOWS\system32\MSVCRT.dll
0x6d670000 - 0x6d804000 	O:\prog_instalados\jre1.5.0_06\bin\client\jvm.dll
0x76b00000 - 0x76b2e000 	C:\WINDOWS\system32\WINMM.dll
0x6d280000 - 0x6d288000 	O:\prog_instalados\jre1.5.0_06\bin\hpi.dll
0x76bb0000 - 0x76bbb000 	C:\WINDOWS\system32\PSAPI.DLL
0x6d640000 - 0x6d64c000 	O:\prog_instalados\jre1.5.0_06\bin\verify.dll
0x6d300000 - 0x6d31d000 	O:\prog_instalados\jre1.5.0_06\bin\java.dll
0x6d660000 - 0x6d66f000 	O:\prog_instalados\jre1.5.0_06\bin\zip.dll
0x10000000 - 0x10050000 	O:\wpLokku\org.eclipse.swt\swt-win32-3139.dll
0x774b0000 - 0x775ed000 	C:\WINDOWS\system32\ole32.dll
0x58c30000 - 0x58cc7000 	C:\WINDOWS\system32\COMCTL32.dll
0x76360000 - 0x763aa000 	C:\WINDOWS\system32\comdlg32.dll
0x77f40000 - 0x77fb6000 	C:\WINDOWS\system32\SHLWAPI.dll
0x7c9d0000 - 0x7d1ef000 	C:\WINDOWS\system32\SHELL32.dll
0x770f0000 - 0x7717c000 	C:\WINDOWS\system32\OLEAUT32.dll
0x76340000 - 0x7635d000 	C:\WINDOWS\system32\IMM32.dll
0x74d20000 - 0x74d8b000 	C:\WINDOWS\system32\USP10.dll
0x773a0000 - 0x774a2000 	C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll
0x5b150000 - 0x5b188000 	C:\WINDOWS\system32\uxtheme.dll
0x746b0000 - 0x746fb000 	C:\WINDOWS\system32\MSCTF.dll
0x77b10000 - 0x77b32000 	C:\WINDOWS\system32\Apphelp.dll
0x77bd0000 - 0x77bd8000 	C:\WINDOWS\system32\VERSION.dll
0x60150000 - 0x60156000 	O:\workspace3.1_WTP_0.7_RC3\PruebaXPCOM\other\xulrunner-\xulrunner\javaxpcomglue.dll
0x60230000 - 0x60257000 	O:\workspace3.1_WTP_0.7_RC3\PruebaXPCOM\other\xulrunner-\xulrunner\nspr4.dll
0x71a50000 - 0x71a5a000 	C:\WINDOWS\system32\WSOCK32.dll
0x71a30000 - 0x71a47000 	C:\WINDOWS\system32\WS2_32.dll
0x71a20000 - 0x71a28000 	C:\WINDOWS\system32\WS2HELP.dll
0x60300000 - 0x60307000 	O:\workspace3.1_WTP_0.7_RC3\PruebaXPCOM\other\xulrunner-\xulrunner\plc4.dll
0x60310000 - 0x60316000 	O:\workspace3.1_WTP_0.7_RC3\PruebaXPCOM\other\xulrunner-\xulrunner\plds4.dll
0x60160000 - 0x601c9000 	O:\workspace3.1_WTP_0.7_RC3\PruebaXPCOM\other\xulrunner-\xulrunner\js3250.dll
0x603e0000 - 0x60ac3000 	O:\workspace3.1_WTP_0.7_RC3\PruebaXPCOM\other\xulrunner-\xulrunner\xul.dll
0x72f80000 - 0x72fa6000 	C:\WINDOWS\system32\WINSPOOL.DRV
0x603d0000 - 0x603d6000 	O:\workspace3.1_WTP_0.7_RC3\PruebaXPCOM\other\xulrunner-\xulrunner\xpcom.dll
0x76f90000 - 0x7700f000 	C:\WINDOWS\system32\CLBCATQ.DLL
0x77010000 - 0x770e0000 	C:\WINDOWS\system32\COMRes.dll
0x719d0000 - 0x71a10000 	C:\WINDOWS\system32\mswsock.dll
0x66740000 - 0x66799000 	C:\WINDOWS\system32\hnetcfg.dll
0x71a10000 - 0x71a18000 	C:\WINDOWS\System32\wshtcpip.dll
0x74680000 - 0x746aa000 	C:\WINDOWS\system32\msimtf.dll
0x60030000 - 0x60038000 	O:\workspace3.1_WTP_0.7_RC3\PruebaXPCOM\other\xulrunner-\xulrunner\components\pipboot.dll
0x60090000 - 0x600c0000 	O:\workspace3.1_WTP_0.7_RC3\PruebaXPCOM\other\xulrunner-\xulrunner\components\transformiix.dll
0x20000000 - 0x202d6000 	C:\WINDOWS\system32\xpsp2res.dll

VM Arguments:
jvm_args: -Djava.library.path=O:\wpLokku\org.eclipse.swt
java_command: XPathJVMCrash
Launcher Type: SUN_STANDARD

Environment Variables:
PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Archivos de programa\ATI Technologies\ATI Control Panel;C:\Archivos de programa\Archivos comunes\Roxio Shared\DLLShared\
PROCESSOR_IDENTIFIER=x86 Family 15 Model 4 Stepping 3, GenuineIntel

---------------  S Y S T E M  ---------------

OS: Windows XP Build 2600 Service Pack 2

CPU:total 2 family 15, cmov, cx8, fxsr, mmx, sse, sse2, ht

Memory: 4k page, physical 2095180k(1441368k free), swap 4033696k(3082492k free)

vm_info: Java HotSpot(TM) Client VM (1.5.0_06-b05) for windows-x86, built on Nov 10 2005 11:12:14 by "java_re" with MS VC++ 6.0

Comment 1

12 years ago
Is the search.htm file important to recreating this crash?  I replaced that with a site on the internet, but I can't get it to crash.  Could you please post search.htm or some other file which you know to cause a crash.

Comment 2

12 years ago
Created attachment 225874 [details]
File to test JavaXPCOM XPath JVM Crash

Comment 3

12 years ago
I have made test with several html pages and always crash with hight probability. I test with attached searh.html (Google result page) and with other pages. It seems that is more probably to crash when more complex is the page. Can I make more things to solve this problem??

Thanks for working in JavaXPCOM.

PD: Sorry for my bad english

Comment 4

12 years ago
OK, I did get a crash when viewing the provided file.  Although, I seem to get a crash with a different signature than you do;  maybe because I'm running a debug build?  Unfortunately, I cannot get the debugger to attach and debug the process.

But I did try with a XULRunner 1.8.1 branch build and I didn't get any crashes.  I recently checked in fixes for several crashers on the 1.8.1 branch.  Unfortunately, there are no Win32 nightly builds for the XULRunner 1.8.1 branch.  If you wish to test, you can build your own XULRunner against the MOZILLA_1_8_BRANCH tag.

For now, marking this as WORKSFORME.  If you still see this crash with XULRunner 1.8.1, please reopen this bug.
Last Resolved: 12 years ago
Resolution: --- → WORKSFORME
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.