Re: [bdbxml] Crash in dbxml_javaJNI.XmlResults_next__SWIG_0
George Feinberg <[email protected]> Fri, 9 Sep 2005 15:22:52 -0400
| Newsgroups | gmane.comp.db.dbxml.general |
|---|---|
| Message-ID | <[email protected]> |
Thomas, The problem is that your main thread of execution is closing the container and manager before the child threads are through with them. This results in deallocating objects and resources out from underneath the child threads and unpredictable things happen when freed memory is accessed in the underlying C++ code. You need to manage your threads and ensure that none of them are still using BDB XML resources when you close the container and manager. I believe that others have seen this problem, and it may be the same issue. The closing/deleting of shared XmlContainer and XmlManager objects in Java will ignore reference counting, and destroy the underlying native objects. There are a couple of ways to manage this. First, you really must simply share the XmlManager instance, and make sure that does not go away. Second, you can safely share the same XmlContainer object among threads as long as you make sure it doesn't get deleted or closed while a thread is active. You can also safely construct multiple XmlContainer objects by calling XmlManager.openContainer() on the same container name. Multiple open calls will return multiple references to the *same* underlying XmlContainer object in C++. HOWEVER, when destroying those objects, be sure to call XmlContainer.delete() and NOT XmlContainer.close(). The close() method will ignore reference counting. In general, the close() methods on XmlManager and XmlContainer should be avoided. The delete() methods do what you want most of the time. Regards, George > George Feinberg wrote: > >> You should share a single XmlManager and open XmlContainer >> object among threads, and only close when the application is >> exiting. >> > > Hi George, > I rewrote the Testcase so that all Threads are using the same > XMLManager and XMLContainer objects > (see ftp://ftp.suse.com/pub/people/freitag/dbxml/ > MultithreadingTestCase.java). > The db is now created inline. > Unfortunately the error still happens in > [libdbxml_java-2.1.so+0x23ae0a] > Java_com_sleepycat_dbxml_dbxml_1javaJNI_XmlResults_1next_1_1SWIG_10 > +0xb0 . > ------------------------------------------ To remove yourself from this list, send an email to [email protected]