From: jdornan at stanford dot edu Operating system: All PHP version: 5.2.10 PHP Bug Type: DBM/DBA related Bug description: Error in dba_exists C code
Description: ------------ Using dba_exists with a file opened with dba_popen and the db4 handler will result in an error. Notice: dba_exists(): DB_THREAD mandates memory allocation flag on DBT data I found a similar problem was reported before for dba_fetch. Since dba_fetch and dba_exists share common code it was clear to see how this error could be fixed. Here is a simple diff between the original file and the fixed version. *** dba_db4.c 2009-07-31 13:24:14.000000000 -0400 --- dba_db4.c.fixed 2009-07-31 13:27:49.000000000 -0400 *************** *** 175,181 **** --- 175,187 ---- DB4_GKEY; memset(&gval, 0, sizeof(gval)); + if (info->flags & DBA_PERSISTENT) { + gval.flags |= DB_DBT_MALLOC; + } if (!dba->dbp->get(dba->dbp, NULL, &gkey, &gval, 0)) { + if (info->flags & DBA_PERSISTENT) { + free(gval.data); + } return SUCCESS; } return FAILURE; I checked an the error still exists in the 5.2 snapshot. Reproduce code: --------------- Test #1 <?PHP $db = dba_popen('test.db4', 'c', 'db4'); dba_insert('b0rk', 'b0rk', $db); if (dba_exists('b0rk', $db) == true) { echo 'Yes, we have b0rk!' . PHP_EOL; } ?> Test #2 <?PHP error_reporting(E_ALL); $db = dba_popen('test.db4', 'c', 'db4'); dba_insert('b0rk', 'b0rk', $db); if (dba_exists('b0rk', $db) == true) { echo 'Yes, we have b0rk!' . PHP_EOL; } ?> Expected result: ---------------- Yes, we have b0rk! Actual result: -------------- Test #1 Nothing. Test #2 Notice: dba_exists(): DB_THREAD mandates memory allocation flag on DBT data in /tmp/test2.php on line 8 -- Edit bug report at http://bugs.php.net/?id=49125&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=49125&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=49125&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=49125&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=49125&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=49125&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=49125&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=49125&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=49125&r=needscript Try newer version: http://bugs.php.net/fix.php?id=49125&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=49125&r=support Expected behavior: http://bugs.php.net/fix.php?id=49125&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=49125&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=49125&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=49125&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49125&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=49125&r=dst IIS Stability: http://bugs.php.net/fix.php?id=49125&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=49125&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=49125&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=49125&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=49125&r=mysqlcfg