Issue Details (XML | Word | Printable)

Key: MODPYTHON-69
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Jim Gallacher
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
mod_python

Potential deadlock in psp cache

Created: 09/Aug/05 10:58 AM   Updated: 05/Mar/06 02:16 PM
Component/s: publisher
Affects Version/s: 3.2.7
Fix Version/s: 3.2.7

Time Tracking:
Not Specified

Environment: All

Resolution Date: 10/Aug/05 09:19 PM


 Description  « Hide
This issue was discussed on the python-dev mailing list but not followed up on. Fixing that now.

In psp.py

def dbm_cache_store(srv, dbmfile, filename, mtime, val):

    dbm_type = dbm_cache_type(dbmfile)
    ### potential deadlock here! ###
    _apache._global_lock(srv, "pspcache")
    try:
        dbm = dbm_type.open(dbmfile, 'c')
        dbm[filename] = "%d %s" % (mtime, code2str(val))
    finally:
        try: dbm.close()
        except: pass
        _apache._global_unlock(srv, "pspcache")

"pspcache" will hash to one of 31 mutexes. Therefore there is a 1 in 31 chance for a hash collision if a session is used in the same request, which would result in a deadlock. (This has been confirmed by testing.)

Most obvious solution is to use the global lock 0, which will serialize all accesses to either pspcache.dbm. Global lock 0 is also used by DbmSession, but since the lock is not held for the duration of the request there should not be any additional deadlock issues.

The fix is to replace the _apache._global_lock(srv, "pspcache") with
_apache._global_lock(srv, None, 0)

The corresponding lock handling in dbm_cache_get() will also need the same fix.

I will commit the this fix shortly.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
There are no comments yet on this issue.