Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93401 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99392 invoked from network); 19 May 2016 18:35:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 May 2016 18:35:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.218.54 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.218.54 mail-oi0-f54.google.com Received: from [209.85.218.54] ([209.85.218.54:35662] helo=mail-oi0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DE/E2-05406-D870E375 for ; Thu, 19 May 2016 14:35:58 -0400 Received: by mail-oi0-f54.google.com with SMTP id x19so143118190oix.2 for ; Thu, 19 May 2016 11:35:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mindplay-dk.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=bIqTF/XyT5zXuGFZh8YmmouepLWLs1B3m27C5cYTGdM=; b=MaGMOUKFgGV2lbHAcbU0Se8NSoCHE1P82tBE5dI/ebrimlJC7DVKbs21BJRTtOx+ea RPM5Lo8z4UP0EurppYVCAYUsfphfTxocPibgYnFqNwkoNMnPIhx4KOeutFaAGf5dm2AC ex2ktaupyciCRksBH/Mj4Z3CBt4XzWk+rvahY85nony7SCZeMzb/DQmCR79wmNK6aerb zv28+UeOfWa8IiEORa/B1p+G/juwUxv400D9sg/sq/E0jjnboHOa4G+jf5W95xhRmQIz WI8bYm2q/XvsobPDpRdWy5R4ROsRbhhmoqqMocSAWLta+fwaHmNID+mAzpCDl0durekk XD2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=bIqTF/XyT5zXuGFZh8YmmouepLWLs1B3m27C5cYTGdM=; b=RD253UFvnZ0ygSmvfsgkBo+p5RTJuG21U+7vLhp1Bq/KkxgNSZqwsKdQhS8Jn8c0Vm OFEJ7fsvZeKBp4LWwrNpn7PRai9FJkXzWDkl215DqhXTCuDuicYOWKk+N3kwmEKb477f SkMYgvpWXH5D2T4ZSHnLCy7ttwnHp703eojpgBpexD6UN8Qz8cPdSfzZnfxv/TYmwWOW 61NADVOC7t8DEXK88Uf9JhnlLKn2fC+oyax0YmrZcIjiHs03fUwosn9uWmAX8e28728U IO7R9Z3yYBygM1z9aq32GMPe2HTnb1OWdJc+a6mbapj29Bktvxw0QieAVL74pTp21ZeL Qu5g== X-Gm-Message-State: AOPr4FXKioRzMnSWDefKgV3VGDgGVnb3jhHA+GY14hPZ0/k7HuTY+xdfz/LtpTgwkpVLWsNuFNpRWHxkILyWnQ== MIME-Version: 1.0 X-Received: by 10.157.13.167 with SMTP id 36mr9587041ots.134.1463682955034; Thu, 19 May 2016 11:35:55 -0700 (PDT) Received: by 10.157.44.214 with HTTP; Thu, 19 May 2016 11:35:54 -0700 (PDT) In-Reply-To: References: <72f547d6-5fcf-3cd2-960d-cb612a429e47@php.net> Date: Thu, 19 May 2016 20:35:54 +0200 Message-ID: To: Niklas Keller Cc: Sebastian Bergmann , PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Exception::getLine() From: rasmus@mindplay.dk (Rasmus Schultz) > Exceptions in PHP are always populated upon creation Wow. Well, I've always wondered why the throw site wasn't in the stack trace - this explains that. This is inconsistent with at least JavaScript and C#, where the stack trace is populated at the throw site. (Probably others?) That doesn't really make any sense to me, for a number of reasons. First, who cares where the Exception was constructed? That has no relevance, and it's often a factory method or in some cases a more complex facility, such as the one in Doctrine DBAL that maps PDO error info to an Exception. You will miss the actual throw site - unless it happens to be the same site as where the constructor was invoked, but there's no guarantee of that. When exceptions get re-thrown, there is no trace of the actual site from where the unhandled Exception was thrown - you're lugging around a stack trace that doesn't actually have the current stack. Technically, every throw is a new exception "flow" - even if you're recycling the Exception instance, it's the throw statement that starts the unique stack unwind from the throw site; it's where the action happens. What's important then, is the throw statement, not the object, since the site where the object happens to get created has no bearing on the stack at the time when the exception gets thrown or re-thrown. In other words, throw new Exception() only happens to work most of the time because the throw and new statements happen to be issued at the same site. This is wonky. Can we fix it? On Thu, May 19, 2016 at 3:05 PM, Niklas Keller wrote: > Sebastian Bergmann schrieb am Do., 19. Mai 2016 14:12: > >> Am 19.05.2016 um 13:14 schrieb Rasmus Schultz: >> > Does this work as intended? >> >> According to https://bugs.php.net/bug.php?id=64910 it does :-( >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php > > > Resending to complete list: > > Yes, this is intended. Exceptions in PHP are always populated upon creation. > > Please note the already mentioned issues with rethrowing and also, that > some exceptions might not get thrown at all, e.g. because of the use of > promises.