php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39653 BDB-4.5 include, older BDB linked
Submitted: 2006-11-28 00:30 UTC Modified: 2006-11-28 11:41 UTC
From: vesely at tana dot it Assigned:
Status: Closed Package: DBM/DBA related
PHP Version: 4.4.4 OS: unix
Private report: No CVE-ID:
 [2006-11-28 00:30 UTC] vesely at tana dot it
Description:
------------
Please add tests for db-4.5 and newer: the compilation does not fail if by chance an older db-4.1 (in my case) existed.
However, when calling dbd->set_errcall the process crashes with pc=0. That happens because the DB structure changed and newer elements have been inserted in the middle of it, rather than at the bottom.

Hopefully, one day BDB will come with an official m4 macro. I already asked them...

One more thing, the errcall has different arguments in 4.5:
--- ./ext/dba/dba_db4.c%    2006-11-27 23:54:31.021697000 +0100
+++ ./ext/dba/dba_db4.c    2006-11-27 23:54:31.031696000 +0100
@@ -35,7 +35,7 @@
#include <db.h>
#endif

-static void php_dba_db4_errcall_fcn(const char *errpfx, char *msg)
+static void php_dba_db4_errcall_fcn(const DB_ENV*env, const char *errpfx, const char *msg)
{
    TSRMLS_FETCH();
     


Reproduce code:
---------------
This was trapped in the test suite. (Since the program aborted its output was different.)


Expected result:
----------------
database handler: db4
3NYNYY
Content String 2
Content 2 replaced
Read during write: not allowed
Content 2 replaced 2nd time
The 6th value
array(3) {
 ["key number 6"]=>
 string(13) "The 6th value"
 ["key2"]=>
 string(27) "Content 2 replaced 2nd time"
 ["key5"]=>
 string(23) "The last content string"
}


Actual result:
--------------
database handler: db4

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-28 00:40 UTC] tony2001@php.net
Elaborate please on how to reproduce it, what is this patch supposed to fix and why.

>Please add tests for db-4.5 and newer: the compilation >does not fail if by chance an older db-4.1 (in my case) existed.
This likely means you're messing different headers and libraries, which is in no way PHP problem.
 [2006-11-28 01:06 UTC] vesely at tana dot it
To reproduce the bug you must install BDB-4.5 (probably 4.4 also fails) over an existing BDB-4.1 (probably 4.3, 4.2, or 4.0 would also reproduce the crash). Then configure

  --with-db4
or, say,
  --with-db4=/usr/local/lib/libdb-4.5

I still had libdb-4.1, for programs compiled before I upgraded. However, only the most recent db.h remained installed. After libdb-4.1's db_create, the virtual function bdb->set_errcall appears to be NULL to programs referring to bdb-4.5's included structure definition.

The configure script won't complain, the compilations looks fine, but libphp4.la mentions libdb-4.1. That's because the configure scripts only tests for versions 4.3 and below.


The patch (broken on pasting) only fixes a compiler warning. It's not much relevant until the errcall will not be actually called (presumably after a runtime error). Even then, only the error reporting will be broken, not the functionality.
 [2006-11-28 10:01 UTC] tony2001@php.net
Please apply this patch: http://tony2001.phpclub.net/dev/tmp/bug39653.diff (patch -p0 < bug39653.diff).
After applying it, please run the following commands:
make clean
rm configure
./buildconf
./config.nice
make
Please check if it works after that.
 [2006-11-28 11:25 UTC] vesely at tana dot it
I bet that patch works, but it's difficult for me to test it.
I've done the following, which works:
--- configure%    2006-11-28 10:53:19.851446000 +0100
+++ configure    2006-11-28 10:53:19.981427000 +0100
@@ -26166,7 +26166,7 @@
      fi
    done
    -  for LIB in db-4.3 db-4.2 db-4.1 db-4.0 db-4 db4 db; do
+  for LIB in db-4.5 db-4.3 db-4.2 db-4.1 db-4.0 db-4 db4 db; do
    if test -f $THIS_PREFIX/lib/lib$LIB.a -o -f $THIS_PREFIX/lib/lib$LIB.$SHLIB_SUFFIX_NAME; then

I guess that's about the same as the patch you produced,
from an end-user perspective - thanx
 [2006-11-28 11:41 UTC] tony2001@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 23:01:58 2014 UTC