Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85424 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77654 invoked from network); 23 Mar 2015 11:36:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Mar 2015 11:36:44 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.174 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.174 mail-wi0-f174.google.com Received: from [209.85.212.174] ([209.85.212.174:38513] helo=mail-wi0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 45/D4-44294-ACAFF055 for ; Mon, 23 Mar 2015 06:36:42 -0500 Received: by wibgn9 with SMTP id gn9so59464648wib.1 for ; Mon, 23 Mar 2015 04:36:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=wKyuG3cLDULLYUvWEwiBuPBx21z6iwiBnA8R550KB9w=; b=qN7No4JttyR3qG+ct4o51L8B+vu6Ooti64pgAMvEFCLey4ezXLFg1byzU1RocgGtO3 28r7lHernWNvIP2Ski/c+kYBF8XpgDJ9hNGx47zUNK9z9A0P/KayRVJEMu9dEUTNunkq ghzKAtXa3XkqAqX0IlSAhjoaGxjrmDvrlKSTrEwv/+AA1gSychOJfhbn212qnXUQY+Ip nzKRNnp5K1a9nbSYmYPDTTf/oV9G8rJePYN1scuIVYxusraqdXQIDImBcuIidSIEHkMb CmAFSQuP4RXoD6ThNpz04cIHD4Ni+ke4ad9c253YLqXobWPus3ug0mYAQSlbSJ0vbD64 iDYw== X-Received: by 10.180.89.34 with SMTP id bl2mr18766207wib.23.1427110598525; Mon, 23 Mar 2015 04:36:38 -0700 (PDT) Received: from [192.168.0.159] ([62.189.198.114]) by mx.google.com with ESMTPSA id jt8sm10816073wid.4.2015.03.23.04.36.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Mar 2015 04:36:37 -0700 (PDT) Message-ID: <550FFAA5.5090004@gmail.com> Date: Mon, 23 Mar 2015 11:36:05 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: internals@lists.php.net References: <550FA2ED.6080000@gmail.com> In-Reply-To: <550FA2ED.6080000@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Serializing exceptions From: rowan.collins@gmail.com (Rowan Collins) Stanislav Malyshev wrote on 23/03/2015 05:21: > Hi! > > Looking into some issue, I've discovered that, to my surprise, > Exceptions are serializable. Except that it doesn't always work of > course (e.g. see http://stackoverflow.com/q/9747813/214196) because > exceptions contain backtraces, and those can contain non-serializable > objects. So in reality, you never know if you can serialize it or not. > > So, I wonder - would it be ok to make exceptions not serializable at > all? I think that would prevent major WTF factor when people try it and > it randomly fails. > > Thoughts? I came upon exactly this situation some time ago, and posted to the list about it: http://marc.info/?l=php-internals&m=138118333112741&w=2 The options I presented there are: 1) Mark all exceptions as non-serializable, as you suggest, removing the surprise. 2) Don't capture args in exceptions backtraces, with the additional benefit of destructors firing more predictably. 3) Strip args out of the backtrace when serializing. 4) Have a function to strip the backtrace ready to serialize, and prevent serialization if it hasn't been called. Option 1 is the simplest, but just as many have questioned the need to serialize exceptions, I would question the need for their backtraces to contain every argument passed to every function in the stack, so would tend towards option 2. AFAIK, no unserializable information is stored outside the 'args' element of the backtrace items. Regards, -- Rowan Collins [IMSoP]