Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126117 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 363071A00BD for ; Fri, 6 Dec 2024 01:08:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1733447139; bh=HWrbmXp70QH44cXIE13blJcXFzS/bLdczwYHNCq/jR4=; h=References:In-Reply-To:Reply-To:From:Date:Subject:To:From; b=la4zFrz1/jI7bcvHTQByBbqFiuz2Xi87JSsoelrrCFhKQifvZeQ6DfTN4h+BYOvzb oA+5HQD80laso71ampOTfyKpN/zy6ChVBGNDmqBYe5OZ+bekUZeab7y1K1NLK+Io2T fpQw7IXxQ0GxQCH0H/55crx/+Jx9sjI7qzCVl0o63oz02VPvbpqtcmWqxCup6wU951 gAmHIBi7Z4k7TAdCzfJLv6ZPgE7A//QjZWC1E5prqBI7IN7fqxspCou265jFIZwn/h OQePRq7d6NwtFs7t66iIT+LxeB8c8auNvzQT7j2+9AXA3xayDlbFJHWWAjru3SFd+m 7X7ZS7HF9EByw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AA6B2180042 for ; Fri, 6 Dec 2024 01:05:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: * X-Spam-Status: No, score=1.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, FREEMAIL_REPLYTO,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-io1-f50.google.com (mail-io1-f50.google.com [209.85.166.50]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 6 Dec 2024 01:05:37 +0000 (UTC) Received: by mail-io1-f50.google.com with SMTP id ca18e2360f4ac-84192e4788dso49720939f.2 for ; Thu, 05 Dec 2024 17:08:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733447323; x=1734052123; darn=lists.php.net; h=content-transfer-encoding:to:subject:message-id:date:from:reply-to :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=HWrbmXp70QH44cXIE13blJcXFzS/bLdczwYHNCq/jR4=; b=debektq0hIL0CS8yYuDejEEaRDAs+QsJYyoImSTQWEuuAn+rxTW7BUJQ8YQR1J6uI2 8+KRsJ6mYsYboNLT+4c0FR/dwPDnYPc494RCTGttJbZWLKVHd36Ea7wPVHnGaI7ReXuB wUO8XMRdBTaJ5pH4wLScxCjaRySjmpVwV7HvwXVa1eZSI6UJWYvLOTg06xYH/0H3oIEb 5A/a94kxwirBwn9Ii7tSNZUqJ4fgahChWfT/gMDlJ2rgYxpOO0wX4itMzOXQ5nPmr8U0 BmxFF3TYwCRhH+ucL/wVycD5L89+We9gnu2CljYoiL6vvbTir0FjEgls3wpyZcOnbZCh ijTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733447323; x=1734052123; h=content-transfer-encoding:to:subject:message-id:date:from:reply-to :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HWrbmXp70QH44cXIE13blJcXFzS/bLdczwYHNCq/jR4=; b=oUzPwNxsBNJAKiOcVMylKX07GFITUZSYPcuk5jMbfC/PvA6f4vljT74Kd/KdgA3YKN 2hribT6mwFLwqKD+6XAtKem1sRdY6W1JbSK2M/kbK71HVNoV8Q1pJ4DaZxiD236dkVBv 7W7U98froxHKEC/YHc3vzSH3mgoOCW4SPHblT+I9PktXyOM1fcyRg6sHABJ4PZ/T/rUj KA8/D4rW4OJQTCbeDslSDvg9Ycyi78a9VTKOe5lKj8YGM0AliiDglyiaTFLOE7hBFKO2 cqm/pX5fLHo3rmvbQkgx1NcUPzQao7IfIdtdUeQOpBdgk9pq81OS6xbb2NODPbxjBrGB VR6Q== X-Gm-Message-State: AOJu0YxUAm2eZJ01sdBQVx+MjUogxaI3i3lAZFR2XjIBE6GmrrIX5MTj Y6Ed0bjqXpELNShGKfK4AGeninz+Ygxf+drqDN973q2CzSiiHmoHndPpro2fTWGOHq3cA630svb jlh1vq3Vj4RrOhxzcpphKM8A2gtXKIVM/ X-Gm-Gg: ASbGncsN4Y93b7nLcI0Vj1YSSYLYLVpG/N98D2pHSz8t1WuNtALbxaz9x6kORH8Q1Bq jri7qw0f0cOZsyiV+zQe6o/yJVKKKXCE7eOZInl5xhPswhe0Tg4ae0NgpA4Wqm21h X-Google-Smtp-Source: AGHT+IGB8jz0XHB/LdrBacyc1LdONOyVyDpdt1qgCiGKNHk0zW6bZPpkJJkze29967iZbamfs4KfebZPaYi9+h8556Y= X-Received: by 2002:a05:6602:3fc1:b0:841:a80a:f536 with SMTP id ca18e2360f4ac-8447e361dd1mr190300539f.14.1733447323284; Thu, 05 Dec 2024 17:08:43 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <8f268a8e-1646-455e-a1c2-b030581dcb9f@bastelstu.be> In-Reply-To: <8f268a8e-1646-455e-a1c2-b030581dcb9f@bastelstu.be> Reply-To: erictnorris@gmail.com Date: Thu, 5 Dec 2024 20:08:27 -0500 Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] Error backtraces v2 To: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: eric.t.norris@gmail.com (Eric Norris) Hello, On Thu, Dec 5, 2024 at 5:31=E2=80=AFPM Tim D=C3=BCsterhus wrote: > > Hi > > Thank you for your RFC. This time I'm making sure to comment already > during the discussion period :-) Haha, thank you! I appreciate the feedback as always. > > On 12/5/24 21:57, Eric Norris wrote: > > https://wiki.php.net/rfc/error_backtraces_v2 > > > > The RFC currently has two voting choices, the first is to accept an > > INI setting to configure an error mask for backtraces, and the second > > is to choose the default value for the error mask. > > You are not restricted to Yes/No votes for the voting widgets. I suggest > to rephrase the second voting widget to: > > "What should the default value of the 'error_backtrace_recording' INI be?= " > > - E_FATAL_ERRORS > - 0 > > This avoids the complicated sentence above the voting widget. Good point. > > The =E2=80=9Cphp.ini Defaults=E2=80=9D section should probably refer to t= he voting > widget as well. > > The first voting widget would probably be better phrased as: > > "Add the 'error_backtrace_recording' INI as described?" I'm a little nervous about this change, because I was hoping to be a little more open-ended. For example, I'm not tied to the name 'error_backtrace_recording', so I wouldn't want someone to vote 'no' because they didn't like the setting name. Secondly, maybe we don't want the zend global (which I'll actually get to in a bit), and similarly I wouldn't want someone to vote 'no' because of that; I don't actually care about whether it's a global or not, I only care about getting backtraces for fatal errors. Maybe this is a little bit of an overreaction from my previous RFC, in that I'm trying to give myself more room for differing implementations while achieving my primary goal. What are your thoughts here? > > Normally one would expect the "Unlocked" to be printed between "Done" > and "After", but this is not the case, because the Exception in the > global keeps a reference to $lock within its backtrace. This would be > the same if the Exception would instead be a `trigger_error()` that > remains available via `error_get_last()`. > > In other words, we would have a INI setting that changes application > behavior in subtle ways, which is a no-no. Great example, thank you. Since you are stating this is problematic - and I don't necessarily disagree - does this make allowing backtraces as implemented for non-fatal errors a non-starter? Presumably having a backtrace for a fatal error doesn't matter since everything will soon be destroyed in the process of shutting down. > For the previous RFC this apparently was a non-issue, because the stack > was stored as a string. But for your RFC this is an issue, because based > on the tests it's stored as an array. That's a good point; I hadn't made that connection when I made the change to use an array (which was an add-on suggestion by nikic, separate from the error mask suggestion). I think this is fundamentally an issue even without the change to error_get_last, since I'm storing the backtrace in a zend global. I would have preferred to make this a parameter to zend_error_cb, but I thought that changing the signature of that method might be too much of a backwards compatibility break (though this would only affect extensions). Making it a parameter would shorten the lifetime of the trace, and PHP's zend_error_cb could store that trace as a string for error_get_last. > At the very least this gotcha should clearly be noted in the RFC text. Right, but of course if that means the RFC will fail, I'd rather implement it differently upfront. Thinking about the options I see here: - We could make error backtraces non-configurable and only for fatal errors, which I believe means we can ignore the lifecycle issue, since application code will switch into shutdown mode. We should still mention the caveat, however, as it still means that the destructors won't fire until after all of the application's shutdown code has run. - We could keep error backtraces configurable as it is now in the RFC, but change zend_error_cb to take the trace as an optional parameter, and not use a global. php_error_cb could store the trace as a string, which could be used by error_get_last. This feels slightly better to me than the next option. - We could keep error backtraces configurable as it is now in the RFC, but store a string in the zend global. For some reason, this doesn't feel "right" to me, since we'd be giving up the structured data in the array. - We could remove arguments from the backtrace. This feels wrong as well, since it would make them different from exceptions. - We could keep the status quo, and note the caveat. Are there any other options people can think of? What are internals' preferences for this?