Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126121 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 E02101A00BD for ; Wed, 11 Dec 2024 04:50:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1733892428; bh=KzMjemN1Cq+eASBfcfNxCZ6SqFwQRV9GT91Qq6GroAE=; h=References:In-Reply-To:Reply-To:From:Date:Subject:To:From; b=Bs3Ej3PoNoWtGuK7rjUha0N4oveBe+njzfJ3zCifKkvee/+YB7PBNcQHhhT5j7SD2 W4uowzo0TcAWcRrihJtyoxNECCbi3LqQLRDm5h6Q4LMYgZG//b9J+jtb5lQLoQ1a0Q LMJ5da4p6EAEnX82LzNO49f7kjBRkrW7xVpFN2/qFO9FQYuzdEMa0oks0SJoQEN12n vQL3ym+mphIPD59ffL+4j9rBblW2Le4Ktk028ms039/Zuv83lRTRer3ncV8w+v1Qe5 l9/6Pmp2jVvUO09SiDPPJQ9IiSxjesAKLK10E2P34Z1ubcNAlumZTQ6N4DhBa9i5wZ +cmZf+RIo4LRg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9A0FF18003C for ; Wed, 11 Dec 2024 04:47:06 +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-il1-f181.google.com (mail-il1-f181.google.com [209.85.166.181]) (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 ; Wed, 11 Dec 2024 04:47:06 +0000 (UTC) Received: by mail-il1-f181.google.com with SMTP id e9e14a558f8ab-3a7750318a2so43166965ab.2 for ; Tue, 10 Dec 2024 20:50:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733892611; x=1734497411; darn=lists.php.net; h=to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=KzMjemN1Cq+eASBfcfNxCZ6SqFwQRV9GT91Qq6GroAE=; b=G+ds04piWaR9XPmZe+ccv4Spi/xQxMfzOOV6H6jvV2lI2pq73Oh8Wumo0vufVA1POR 7KJFTL2aZHsm2QATgXwGsXTBiy1j3YcRPcr+ikb3pCgBzXw2IEjvH3K4zZd3odxmOkz3 FIoO+Cah371XolCIgh3hJPWE2FutQEFhTPN86O5DWdN+hrUef6no0h47Tysezvmmolpi GGclpAx5LwaJbxH40NpF3IMBSB/AedbC0RYhIPwqb4VdiC5qYPUxyNLtR6oJUjOw5gdv apQdaF65WPLBp2BzRIqZycRiTxnSO1wdev1LbpKxSe5sZ41NgrqeUPpowdpr36chh2aw bUfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733892611; x=1734497411; h=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=KzMjemN1Cq+eASBfcfNxCZ6SqFwQRV9GT91Qq6GroAE=; b=pczAZnAu+HHjN+howGn/GwYOVqAobhxiMpbIGVQu8GnncbwVMWhBiEzibWdBPK2dm9 3VsVAVXCIGNjY242ct7IgLxHdpdEV2y9zxKMUt/w4lYH6ZSaWwTKiXSEhSK1dkEqfpXH 6HgQwn163NdPwqLCpQyjfG1cz/v/yYEkQvJGFT2C6PSurXfwt6W/emDn3Gd4CRhuBkGb UEf09bJd/p2EYt+EnUCiH+1JvCdzYtjvnb2wnlj1QDng1J3wdjjG6kIXSQ0v9UZBWC+H LTC796kTx6pdPl+mZLvlclsglI3BJhKRvUL/8kWUNoWJ43F73sDbYfVdCtboosoaeJSV t2RQ== X-Gm-Message-State: AOJu0YyvzeSd5gkXl09i3wKnj4/QFgMPjELGhqdr5jy9Pmw9Nn2sSW7Z EvwiyyHI67BGjLFSLt4tKWi0o5A/OlvQb/hlWaXbmOHaDebjWAsmqUQ7DRYB99dDow46VvOaceN 8jf0MoXsYQcDpprt1B9Jqd0UzjguuB+dd X-Gm-Gg: ASbGncvgrCy3urctWz5kZjnt8/bT3hRyzVq7mTEpA43SjeF44KEJRfkWrgMBs3LsG6U vJKVPdZGhUkSVk2PHtNr2NaRRHA9xFlG3+5ks14PoyqfNE6PnDVMDLpE2wy4Sy+fZ1FFJJg== X-Google-Smtp-Source: AGHT+IGZ69pX2UGs6QiXYGVSDjaylQUpfrAzcFfUH/ACzoXDJkYQYNNvW3ZAu8QS9Omf3PTMf1HAj3hV05Zk/01SSpM= X-Received: by 2002:a92:ca06:0:b0:3a7:9670:7abb with SMTP id e9e14a558f8ab-3aa08f66015mr16086205ab.15.1733892610670; Tue, 10 Dec 2024 20:50:10 -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: Reply-To: erictnorris@gmail.com Date: Tue, 10 Dec 2024 23:49:54 -0500 Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] Error backtraces v2 To: PHP internals Content-Type: text/plain; charset="UTF-8" From: eric.t.norris@gmail.com (Eric Norris) > Yes, I agree that having a stacktracke for fatal errors is a non-issue. > For non-fatal errors the INI setting definitely is a problem. > Unconditionally having a stacktrace for non-fatal errors I'm am not yet > sure if this would be a problem or if it would be fine if it is a > RFC-agreed-upon (breaking) change. Given that it's common to turn > warnings and notices into Exceptions and thus to treat them as hard > errors, I'd be inclined to say that the value-add of having backtraces > for them is fairly small compared to the possible impact and that it > makes sense not to include this in the RFC at all. I've updated the RFC to v2.0: I'm now proposing an on-off switch to enable backtraces for fatal errors only. That said, after updating the RFC I've discussed an alternative with my colleagues that I think is worth also discussing here. It occurred to me that the main issue is including the backtrace in error_get_last, but we want the backtrace in error_get_last as there is no other way for user code to get the backtrace for a fatal error, aside from calling error_get_last in shutdown code. If instead we did call the error handler set up in set_error_handler - or call something like that - users could gather the backtrace with debug_backtrace themselves, and log it how they want, or send it elsewhere, whatever. Internally PHP wouldn't need to do anything about the backtrace. Of course users should not be able to actually handle fatal errors, and execution should immediately bail out after calling the handler as it does today upon encountering a fatal error. This could be addressed by either informing users that returning true or false makes no difference for fatal errors, or by introducing a newer error handler concept that had that behavior. There may be a backwards compatibility issue with the former - users might not have written their error handling code with the expectation that it could encounter fatal errors - and that too could be addressed by either making this an INI setting, or again, introducing a newer error handler concept. Either way, exposing fatal errors to user-level code may be a better solution to the problem of errors not having a backtrace. Passing fatal errors to user handler code would potentially make error handling more consistent, and rely less on global state like error_get_last. Also note that calling user-level code after a fatal error is not new; user code registered in register_shutdown_function is called after a fatal error, which again is one source of a need for something like error_get_last. I'm curious if anyone has any immediate reactions - positive or negative - to this line of thinking. Perfect is the enemy of good, so I'd accept moving forward with the RFC as it is now if it is more tenable; I think this idea is worth exploring a little bit before doing so, however.