Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94833 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26711 invoked from network); 4 Aug 2016 18:11:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Aug 2016 18:11:08 -0000 Authentication-Results: pb1.pair.com smtp.mail=bishop.bettini@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=bishop.bettini@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.68 as permitted sender) X-PHP-List-Original-Sender: bishop.bettini@gmail.com X-Host-Fingerprint: 209.85.218.68 mail-oi0-f68.google.com Received: from [209.85.218.68] ([209.85.218.68:35765] helo=mail-oi0-f68.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F0/F9-53111-83583A75 for ; Thu, 04 Aug 2016 14:11:07 -0400 Received: by mail-oi0-f68.google.com with SMTP id w143so26730336oiw.2 for ; Thu, 04 Aug 2016 11:11:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:sender:from:date:message-id:subject:to; bh=JMhTwafU6EPgFVU+p8G1y1dI6OEgXQegEu7POaICc1A=; b=cWGdXYRlYzMlT9ahWry2pWTsxD914VjVJPHPK/f82ktBNVCAS3AImAAC4MU8L4CZv+ HrydsUbPwR122HdfYWO1wmFYeXdv4tEqoTUN89/UKygzlNfejppGWmVWcsLxWWNu0s4N 43z4xq6lD8XdNpkXUcFlU55cTE7crKpofqe3fTTYYO2dcOfEtb7JQz9sgvBpwmhDVUY4 kSBzS5D4Jx4r0QkP0imng5LeDjNL+Xy2CLGnKAfd/G68SI4lS4F31LnM9U4o6MtW3fN8 /RXvmddY9wFEy5BEg/AusTQdeYobEiMuopTrWKkUy29UeHZDU/HDVy0PzJ1SjKLHosHa 8LxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:reply-to:sender:from:date :message-id:subject:to; bh=JMhTwafU6EPgFVU+p8G1y1dI6OEgXQegEu7POaICc1A=; b=jSC1v1T8/WuQaLB9Xn7cFW5R7nhd58hv7Dd6Yhc6+Nu8HKyXCOh/UQYvXz3+z2gp4y 7pcLBeMkd/m4hyp5y/PSAbjWXAU2rfgfPJPbgObEX66gefjF+2gB0vqhWNCnI9hBFCyP 1NpUoopCOESuObBS/iGcCHR9ZOzk6MKgNpDqHD9d5SeiZrkDNOfrMlOe+fxwJNJgi/o9 fK84c+oJIqJBCZ3hzngabPN5U9DEzBtXju1VEllUGr6OIeJZ6IrOtTA3oNEFVK/cgdxb oGJqUOtJAK1Z00cfbwGhkXtkCUTETHweCNmYx5LgqJvd+TA1vH4wxLP6iJH79LNxkQuK rfBg== X-Gm-Message-State: AEkooutYoHOrlD5JSqnsLbft/H4qAy+qmpd3koXoBFfCiDu0LgIC6EfUZ1sfbFSIwqNNW4GkJVuXWpAC146fhg== X-Received: by 10.157.51.124 with SMTP id u57mr9623otd.25.1470334262109; Thu, 04 Aug 2016 11:11:02 -0700 (PDT) MIME-Version: 1.0 Reply-To: bishop@php.net Sender: bishop.bettini@gmail.com Received: by 10.157.34.129 with HTTP; Thu, 4 Aug 2016 11:10:31 -0700 (PDT) Date: Thu, 4 Aug 2016 14:10:31 -0400 X-Google-Sender-Auth: jV5GejuJl0fbhtY2b3ihaRBCSYo Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary=001a1141552464f0b4053942df03 Subject: Tracing exit() From: bishop@php.net (Bishop Bettini) --001a1141552464f0b4053942df03 Content-Type: text/plain; charset=UTF-8 Hi! exit (and its doppelganger die) is a hard stop to the engine and there is little telemetry provided about the circumstances (file, line, message, and code). In source I control, exit is no big deal: I don't use exit! But in library code, exit can be frustrating. register_shutdown_function + debug_backtrace doesn't help, because the trace doesn't flow out of the shutdown function. xdebug helps to find the exit frame, but cannot pinpoint the exact line. It seems like the engine could help with a little extra telemetry. I'm wondering if the shutdown functions could access telemetry: 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(); ?> Or, alternatively, I wonder if a method to convert an exit to an exception would be better: (In all these examples, "callsExit" is vendor code that performs an undesirable exit();) This latter approach feels more modern, at least from a user perspective, but it has the side effect of making exit recoverable. IMO, that's a good thing, because the conditions under which libraries exit may merely be exceptional for consuming applications. 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. 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? bishop --001a1141552464f0b4053942df03--