Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:22740 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73827 invoked by uid 1010); 13 Apr 2006 22:52:30 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 73811 invoked from network); 13 Apr 2006 22:52:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Apr 2006 22:52:30 -0000 X-Host-Fingerprint: 80.74.107.235 mail.zend.com Linux 2.5 (sometimes 2.4) (4) Received: from ([80.74.107.235:53138] helo=mail.zend.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id D9/F8-19715-D26DE344 for ; Thu, 13 Apr 2006 18:52:29 -0400 Received: (qmail 8606 invoked from network); 13 Apr 2006 22:52:25 -0000 Received: from localhost (HELO ANDI-NOTEBOOK.zend.com) (127.0.0.1) by localhost with SMTP; 13 Apr 2006 22:52:25 -0000 Message-ID: <7.0.1.0.2.20060413154916.014b1d88@zend.com> X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 Date: Thu, 13 Apr 2006 15:52:22 -0700 To: Andrei Zmievski , PHP Internals Cc: Dmitry Stogov In-Reply-To: References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Re: Unicode conversion exceptions and memory leaks From: andi@zend.com (Andi Gutmans) As you know, exceptions were designed to be user-land and not for internal functionality. I warned about that more exceptions were being integrated into the extensions; and I especially warned of ideas of integrating them into language constructs such as type hints and conversions. I don't have a good solution for this right now, except for adding a lot of bulk to C extensions and the core and making them overly complicated. Anyway, I'll discuss with Dmitry and see if he has any ideas I didn't think of. re: this specific case. Is it really a good idea for a type conversion to throw an exception? People won't be expecting that from reading the code. They'd most likely only expect methods to throw exceptions... Andi At 03:44 PM 4/13/2006, Andrei Zmievski wrote: >If you run this code in PHP 6 right now, you will get a nice memory >leak notice. > > >unicode_set_error_mode(FROM_UNICODE, U_CONV_ERROR_STOP | >U_CONV_ERROR_EXCEPTION); > >$u = "< \u3844 >"; >try { > $s = (binary)$u; >} catch (UnicodeConversionException $e) { >} > >?> > >/homes/andrei/dev/php-src/Zend/zend_unicode.c(461) : Freeing >0x013FC4E4 (1 bytes), script=e.php > > From what Dmitry tells me, it is impossible to fix this with the > way our exceptions are implemented currently. I trust him on this, > but at the same time I think we need to do something. The > conversions will be happening in a lot of place and being able to > catch an exception, if one results, is an important part of the > workflow. I think Dmitry proposed that we could re-write exceptions > implementation, but also said that it would be a lot of work. I > think we should seriously consider it, though. > >Thoughts? > >-Andrei