bsddb module bug?: doesn't release locks and seg faults

Discussion in 'Python' started by Jane Austine, Aug 14, 2003.

  1. Jane Austine

    Jane Austine Guest

    There is a test code named test_env_close in bsddb/test, but it
    doesn't test the case thoroughly. There seems to be a bug in closing
    the db environment first -- the lock is not released, and sometimes it
    seg-faults.

    Following is the code that shows this bug.

    <code>
    import os
    from bsddb import db

    dir,dbname='test_dbenv','test_db'

    def getDbEnv(dir):
    try:
    os.mkdir(dir)
    except:
    pass
    dbenv = db.DBEnv()
    dbenv.open(dir, db.DB_INIT_CDB| db.DB_CREATE |db.DB_INIT_MPOOL)
    return dbenv

    def getDbHandler(db_env,db_name):
    d = db.DB(dbenv)
    d.open(db_name, db.DB_BTREE, db.DB_CREATE)
    return d

    dbenv=getDbEnv(dir)
    assert dbenv.lock_stat()['nlocks']==0
    d=getDbHandler(dbenv,dbname)
    assert dbenv.lock_stat()['nlocks']==1
    try:
    dbenv.close()
    except db.DBError:
    pass
    else:
    assert 0

    del d
    import gc
    gc.collect()
    dbenv=getDbEnv(dir)
    assert dbenv.lock_stat()['nlocks']==0,'number of current locks should
    be 0' #this fails
    </code>

    If you close dbenv before db handler, the lock is not released.
    Moreover, try this with dbshelve and it segfaults.

    <code>
    >>> from bsddb import dbshelve
    >>> dbenv2=getDbEnv('test_dbenv2')
    >>> d2=dbshelve.open(dbname,dbenv=dbenv2)
    >>> try:

    .... dbenv2.close()
    .... except db.DBError:
    .... pass
    .... else:
    .... assert 0
    ....
    >>>
    >>>

    Exception bsddb._db.DBError: (0, 'DBEnv object has been closed') in
    Segmentation fault
    </code>
     
    Jane Austine, Aug 14, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Neville C. Dempsey
    Replies:
    0
    Views:
    390
    Neville C. Dempsey
    Jun 12, 2005
  2. Skip Montanaro
    Replies:
    1
    Views:
    418
    Bengt Richter
    Jun 26, 2005
  3. grid

    Optimasation and seg faults

    grid, Jul 20, 2005, in forum: C Programming
    Replies:
    11
    Views:
    519
    SM Ryan
    Jul 21, 2005
  4. Replies:
    13
    Views:
    748
  5. sapsi

    QT, ctypes dll and SEG Faults

    sapsi, Aug 17, 2008, in forum: Python
    Replies:
    2
    Views:
    350
    Matthieu Brucher
    Aug 17, 2008
Loading...

Share This Page