Dear All,
I have a problem that I have been able to reduce down to a modified version of example 9 from the Python demo code. The primary modification was to remove the line that deletes the test container from the database. The first time the example is executed everything works perfectly. On subsequent executions, the putDocument fails as expected, but when the environment is closed, it results in an access violation.
I have tried this in two environments:
Windows XP SP3 (32 bit)
Active State Python 2.5.2.2 (32 bit)
Berkeley db XML 2.4.16
Windows Vista SP2 (64 bit)
Active State Python 2.5.4.4 (32 bit)
Berkeley db XML 2.4.16
It appears that there is a corrupted pointer, I received the following error messages:
Vista: Unhandled exception at 0x02895fb2 in python.exe: 0xC0000005: Access violation writing location 0xdbdbdbdb.
XP: Unhandled exception at 0x7c91b21a in python.exe: 0xC0000005: Access violation writing location 0x00000023.
The modified example 9 follows.
Any insight that can be provided would be appreciated.
Thank you - Marie
'''
Created on Sep 24, 2009
@author: Modified from distribution example programs for Python
'''
from bsddb3.db import *
from dbxml import *
book_content = r"<book><title>Knowledge Discovery in Databases.</title></book>"
book_content_ns = r"<book xmlns:books='http://foo.bar.com/books.dtd'><books:title>Knowledge Discovery in Databases.</books:title></book>"
book_name = r"book1"
book_name_ns = r"book1_ns"
if __name__ == '__main__':
environment = DBEnv()
environment.open(None, DB_CREATE|DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN, 0)
try:
mgr = XmlManager(environment, 0)
uc = mgr.createUpdateContext()
container = mgr.createContainer("test.dbxml", DBXML_TRANSACTIONAL)
except Exception:
container = mgr.openContainer("test.dbxml", DBXML_TRANSACTIONAL)
try:
xtxn = mgr.createTransaction();
document = mgr.createDocument()
document.setContent(book_content)
document.setName(book_name)
container.putDocument(xtxn, document, uc)
document = container.getDocument(xtxn, book_name)
s = document.getContent()
print document.getName(), "=", s
xtxn.commit()
#mgr.removeContainer("test.dbxml")
except XmlException, inst:
print "XmlException (", inst.exceptionCode,"): ", inst.what
if inst.exceptionCode == DATABASE_ERROR:
print "Database error code:",inst.dbError
del document # holds ref on container, tried moving to end of try block to no avail
del container # prevents removal
del uc
print "here" # Access violation occurs after this line
environment.close(0)
print "there"