Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94843 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 53836 invoked from network); 4 Aug 2016 23:38:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Aug 2016 23:38:02 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.214.52 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.214.52 mail-it0-f52.google.com Received: from [209.85.214.52] ([209.85.214.52:35706] helo=mail-it0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 65/43-33134-9D1D3A75 for ; Thu, 04 Aug 2016 19:38:01 -0400 Received: by mail-it0-f52.google.com with SMTP id u186so9107754ita.0 for ; Thu, 04 Aug 2016 16:38:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=6zUcFCQ76pkxG6wxDquHtY3DB8PqVkCi/2mrNob3Vow=; b=0DSe5dm8Wrkb/QuIaxszxzE38AXQoia07+e1S9ezB9XGJIYRzLE/+atbFk/Zh/W8GG S7/Y1st9MrpPi9YzJMokXT3wR4d0kza1nFGMsjvdfugpHad1mRZt9PMSnqT9LeMGq26I a/oT28zaF0DoxexP+426fNtPMW1CWHFYUK2cty9cOqVWuLHSis3bisn5VqutB+KW3nbw SS2oAj58PLulLofzXllvs2T99HbIq+IQD6yAKyH8qTvG8B7maxKfTZuGt9ExApRI+l7c Y7a2+bwhP+2IW+cH3OQkj/oYZ/TFIGmIbK/f8ZvwvYtPUIzMieP6tVdvVnPTnRnI+mbO bQ/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=6zUcFCQ76pkxG6wxDquHtY3DB8PqVkCi/2mrNob3Vow=; b=Y5fBoF+9QriS4coPjj9YdM+i+iuIUD4ExaB/mOE5QgCJGmq5D6pEtq5GWviPTmhUXD mK6eVlxtg989pX1HAzSUbdTVzThJilkxxlnSO225rl24bx1exjLbnLkEP15bcJtSfviU VqEnz/WALc0FCer0lEwLu4wpPOsKozGRKgyWHE/uyTfeMdW7NltQY05O6xXpoAx+pzKZ d71fEKOA07ZaHMtZfnkBw31VPQ+KEBNNaZkWadxHCA1NPbEAWw6Ty40VBCC9qABJFHSD 9l20/NnhufXpww7/J0Jhkwal/lf7LIjoDnDL0vn+pyGlo1EpiSEF46ceIEsgEo0r/rlr tKYg== X-Gm-Message-State: AEkoousl+T24JT8Af1xmeCJLwIT8ElxYSRfqJVoFO9CKcA3JxahQ3XsfP5bRSOVaSRAZrU0MMwereOJpBzk9Gg== X-Received: by 10.36.217.68 with SMTP id p65mr658347itg.9.1470353878627; Thu, 04 Aug 2016 16:37:58 -0700 (PDT) MIME-Version: 1.0 Sender: php@golemon.com Received: by 10.36.117.201 with HTTP; Thu, 4 Aug 2016 16:37:57 -0700 (PDT) X-Originating-IP: [107.198.91.68] In-Reply-To: References: Date: Thu, 4 Aug 2016 16:37:57 -0700 X-Google-Sender-Auth: c6t_xPSmdNpVriK0BZkuo1iS1Sg Message-ID: To: Bishop Bettini Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Tracing exit() From: pollita@php.net (Sara Golemon) On Thu, Aug 4, 2016 at 11:10 AM, Bishop Bettini wrote: > I'm wondering if the shutdown functions could access telemetry: > > register_shutdown_function(function () { > > $context = shutdown_get_context(); > > /** array ( 'exit' => array ('file' => '/path/to/Foo.php', 'line' => > 242, 'message' => "Calling exit() because...", 'code' => 0)) */ > // different SAPI may expand on this context > }); > > require 'vendor/autoload.php'; > \Vendor\Package\Class::callsExit(); > ?> > I like this idea! I can easily imagine the frustration of having untrackable calls to exit, and the effort to expose this info for logging is pretty trivial to implement. > Or, alternatively, I wonder if a method to convert an exit to an exception > would be better: > Eh... That feels less-obvious to me for the reasons you stated in your OP. I'm not convinced that being able to recover from an \ExitException is a good thing, but I don't have a compelling reason why it's bad, so I'll keep thinking about that. > However, I'm uncertain of an "exit exception" implementation. Perhaps when > INI enabled, zend_compile_exit could rewrite to emit ZEND_THROW with a > synthetic node. Or all the ZEND_EXIT could be updated to throw instead of > bailout. Don't know. > I'd probably leave the compile step alone and have the opcode handler switch on the INI setting. One lil' integer compare on an instruction meant to *stop* execution isn't going to be a problem. (You wouldn't have exit being called repeatedly in a loop) > TL;DR: Engine support for tracing/trapping/debugging exit helps developers > find and avoid hard exits in dependent code they don't control. Thoughts on > proceeding with an RFC? > +1 from me. -Sara