Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:9476 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4977 invoked by uid 1010); 22 Apr 2004 00:51:00 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 4944 invoked from network); 22 Apr 2004 00:51:00 -0000 Received: from unknown (HELO mail.mbobo.org) (213.133.123.182) by pb1.pair.com with SMTP; 22 Apr 2004 00:51:00 -0000 Received: from localhost (localhost [127.0.0.1]) by mail.mbobo.org (Postfix) with ESMTP id BA6D65775D1; Thu, 22 Apr 2004 02:50:59 +0200 (CEST) Received: from mail.mbobo.org ([127.0.0.1]) by localhost (debian [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 10570-02; Thu, 22 Apr 2004 02:50:58 +0200 (CEST) Received: from [10.200.1.52] (adsl-68-120-96-254.dsl.sntc01.pacbell.net [68.120.96.254]) by mail.mbobo.org (Postfix) with ESMTP id 0C6F85775CB; Thu, 22 Apr 2004 02:50:58 +0200 (CEST) In-Reply-To: <1082583400.12577.19.camel@powah.cc.force-elite.com> References: <1082583400.12577.19.camel@powah.cc.force-elite.com> Mime-Version: 1.0 (Apple Message framework v613) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-ID: <1CA1D9B6-93F7-11D8-9EC0-000A95E073A0@php.net> Content-Transfer-Encoding: 7bit Cc: internals@lists.php.net Date: Wed, 21 Apr 2004 17:50:55 -0700 To: Paul Querna X-Mailer: Apple Mail (2.613) X-Virus-Scanned: by amavisd-new-20030616-p5 (Debian) at mbobo.org Subject: Re: [PHP-DEV] xmlSetGenericErrorFunc Abuse From: sterling@php.net (Sterling Hughes) On Apr 21, 2004, at 2:36 PM, Paul Querna wrote: > The libxml2 Extension in PHP5 uses > > xmlSetGenericErrorFunc(NULL, php_libxml_error_handler); > > This globally(inside the process) sets the libxml2 error hander to > PHP's > own function. > > Why is this bad? > > It clobbers the processing done by anything else that uses libxml2 in > the same process as PHP. > > For a simple example, I use mod_transform ( > http://svn.outoforder.cc/svn/mod_transform ) with Apache 2 as a filter > to process XML documents w/ XSLT into HTML. If there are _any_ errors > in the transformation PHP attempts to take care of them. This causes > Apache to crash because this is not even a PHP request and very quickly > the Error Handler will crash when it tries to get a server context. > > This is not an issue isolated to Apache 2. It could happen in Apache > 1.3 if any other module used libxml2. > Nope - it couldn't. We reset (or we should) the error handler after we are done executing. In processes, only one thing executes at a time, and when PHP is executing we want to override this error handler. > The proper way for PHP to handle this is to not set a Generic Error > function, but rather check the return values of libxml2 functions. > Nope. > This is not like the local-mysql vs system-mysql problem that used to > be > more common. PHP is initializing libxml2 as if it was the only user, > which is not always the case. > Its actually quite different than that problem. This is a problem for people who use threads. People who use threads for serving dynamic webpages with PHP should be castrated and then shot (well, at least castrated, we don't want this problem proliferating.) The solution here is either to use a global context of our own, if libxml2 allows us to do so, use a mutex, or just laugh very hard and very loud when people tell us they have a problem using php in threaded environments. On that note.... bwahhhahahahhahahaha. -Sterling