php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3423 dbmopen() not thread-safe
Submitted: 2000-02-07 22:52 UTC Modified: 2002-10-01 11:36 UTC
From: wagener at tnt dot psychologie dot uni-mannheim dot de Assigned:
Status: Not a bug Package: DBM/DBA related
PHP Version: 3.0.14 OS: Win NT 3.51
Private report: No CVE-ID: None
 [2000-02-07 22:52 UTC] wagener at tnt dot psychologie dot uni-mannheim dot de
The dbm unit isn't capable of handling multiple request on the same .db files more than once. There's indeed some kind of "php-own-locking", but this just makes the whole php fail when it's needed. The following code allows simulating multiple accesses on the same .db file ("shit" must have been created as dbm file before):

function shoot_dbm()
  {  /* this loop should wait until the db is unlocked */
     /* - but it makes the second instance crash */
   do
     {
     $dbShit = dbmopen( "shit", "w" ); 
     }
   while( ! $dbShit );  

   sleep(5); /* simulate some activity in critical part */

   dbmclose( $dbShit ); 
  };

Running this part via two clients, the second get's an "server misconfiguration error" page wit apache.

using a lock file via flock() to "protect" the dbm module from its dumbness doesn't help also. Locking works fine, but the dbm still causes problems (quite strange!).

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-01 11:36 UTC] hholzgra@php.net
some extensions are just not thread-safe as the underlying libs aren't :(

theres a way more general report requesting documentation on tread-safety status for extensions so i'm setting this
one to "Won't fix" (as we'll fix the documentation instead
of fixing all the differend underlying db* libs)

btw: flock() works on process-level only, as threads are part of the same process they all get positive results from flock if the lock is held by another thread in that process
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 08 15:01:28 2024 UTC