ID:               36152
 Updated by:       [EMAIL PROTECTED]
 Reported By:      misiek at dione dot ids dot pl
 Status:           Assigned
 Bug Type:         cURL related
 Operating System: *
 PHP Version:      5CVS, 4CVS (2006-01-25) (snap)
 Assigned To:      mike
 New Comment:

>curl tries to initialize openssl and then to setup own callbacks.
>pgsql via libpq does the same thing.
"curl" here means ext/curl, while ext/pgsql doesn't set its handlers,
libpq does that.
So personally I don't see a way to handle it, if an *external* library
changes callbacks that were set in PHP extension.
I guess the library should be fixed first.


Previous Comments:
------------------------------------------------------------------------

[2006-01-25 11:11:01] misiek at dione dot ids dot pl

This is how I see it. It's not problem in curl module. It's problem
with callback handling in entire php. openssl allows only single
callback function for entire application. curl and pgsql are just two
things that happen to trigger the problem.

Now curl tries to initialize openssl and then to setup own callbacks.
pgsql via libpq does the same thing. It again initializes already
initialized openssl and setupts own callbacks again.

Every next module which uses openssl callbacks will be problematic
unless initialization and callback handling will be done in upper layer
(php itself) once for all modules. Maybe other solution (like
initializing only once in first module) would also work...

------------------------------------------------------------------------

[2006-01-25 10:55:59] [EMAIL PROTECTED]

Mike. this is related to your patch for #33760.
Please take a look.

------------------------------------------------------------------------

[2006-01-25 10:55:49] [EMAIL PROTECTED]

See also bug #33760


------------------------------------------------------------------------

[2006-01-25 10:42:49] misiek at dione dot ids dot pl

This also happens in php4.4.2.

openssl uses globals to store callbacks data which makes things
complicated. libpq and curl allow to manage ssl lockig in application
code (see PQregisterThreadLock() and PQinitSSL() for libpq) so doing
ssl lock management in one place for all modules sounds like possible
solution.

------------------------------------------------------------------------

[2006-01-25 10:28:17] misiek at dione dot ids dot pl

[EMAIL PROTECTED] 16112]# gdb --args /tmp/qq/bin/php config.php
GNU gdb 6.4
Copyright 2005 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and
you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for
details.
This GDB was configured as "i686-pld-linux"...Using host libthread_db
library "/lib/tls/libthread_db.so.1".

(gdb) b CRYPTO_set_locking_callback
Function "CRYPTO_set_locking_callback" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (CRYPTO_set_locking_callback) pending.
(gdb) b int_err_del
Function "int_err_del" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 2 (int_err_del) pending.
(gdb) r
Starting program: /tmp/qq/bin/php config.php
Breakpoint 3 at 0xb78ee736: file cryptlib.c, line 349.
Pending breakpoint "CRYPTO_set_locking_callback" resolved
Breakpoint 4 at 0xb795341a: file err.c, line 354.
Pending breakpoint "int_err_del" resolved

Breakpoint 3, CRYPTO_set_locking_callback (func=0xb7728428
<pq_lockingcallback>) at cryptlib.c:349
349             locking_callback=func;
(gdb) print func
$1 = (void (*)(int, int, const char *, int)) 0xb7728428
<pq_lockingcallback>
(gdb) c
Continuing.
X-Powered-By: PHP/5.1.3-dev
Content-type: text/html


Breakpoint 4, int_err_del () at err.c:354
354             CRYPTO_w_lock(CRYPTO_LOCK_ERR);
(gdb) s
CRYPTO_lock (mode=9, type=1, file=0xb79bf3ad "err.c", line=354) at
cryptlib.c:414
414             if (type < 0)
(gdb) n
429                     if (locking_callback != NULL)
(gdb) print locking_callback
$2 = (void (*)(int, int, const char *, int)) 0xb7728428.
(gdb) print *locking_callback
Cannot access memory at address 0xb7728428
(gdb)      

this trace shows that pq_lockingcallback() was lost somewhere and code
issued from curl tries to use it (callback from pgsql).

Maybe openssl initialization and deinitialization should be somehow
made once for all php modules that use openssl instead of doing per
module init?

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/36152

-- 
Edit this bug report at http://bugs.php.net/?id=36152&edit=1

Reply via email to