Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93435 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48742 invoked from network); 23 May 2016 08:13:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 May 2016 08:13:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=julienpauli@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=julienpauli@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.67 as permitted sender) X-PHP-List-Original-Sender: julienpauli@gmail.com X-Host-Fingerprint: 74.125.82.67 mail-wm0-f67.google.com Received: from [74.125.82.67] ([74.125.82.67:33675] helo=mail-wm0-f67.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 29/C3-14293-C9BB2475 for ; Mon, 23 May 2016 04:13:17 -0400 Received: by mail-wm0-f67.google.com with SMTP id 67so12555097wmg.0 for ; Mon, 23 May 2016 01:13:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=e4u6Yv+YLNTVUB33OdSuSyS4hkg/ZR+QBYnZ08Aw+0E=; b=AXNujfi1iWb2/QgbwJ9j9pBmDKjPYwYqDIj9Lx4tvofYz6qsmjigNIhwzjbAa/Pd+H J2GF+m6DLaEbbg8uRLUTYXhh77IV2EoBxsYhsExcautlHHixrXFi7j35Qats2aywpMbI zbWHqC1Snf+faKvmoP+G8kmozekhiRDq5oacYvuPjAtMtZSZTPSmqtGRGCnrJxIQqBDz vGJydF7JlfJqi9Q8CVruTbofiKadzDlrXJ1EsuZzPeB9YxM35B2DYderw8UI3NwEzBr7 c+UwcnD4/tOtRudB0UwfrTQUMh2i8g0ovIizYRugWs+D+WtmVwMW4rnj/fD5vnCjzs1+ miLQ== 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=e4u6Yv+YLNTVUB33OdSuSyS4hkg/ZR+QBYnZ08Aw+0E=; b=DIg/vofsN2Sz0W540+i/4L9pZZkwUQwF1SOlfCx/XtVbTVcu+rKn3X0Wzv87Q2uc7+ n6YcoAmLzqOvLk9eLcKFAGD0/4Lq+Gx/S21wIELv67vW6HTbsrhEwe6UY7zReWQEukVT RtF7UxGN7ggsHVh9ZfR4LLVYFhrljUW/Rd7LQATJ9rLklvZjkG8o7HXgr6VjJlKBzh/s EVU7w3mi9AuugWfm3BXiP2MHjAEnF60X3BJY+YgYTlHekUvv8fexi1SpWUqk/1IVGuOv E/YDZF8GNl6NF8TbOGaQwZ3kw3E1f4z1eCwo8fvPEjH4m7bheq6ShnScLooPwy5ZGFiJ Lxlw== X-Gm-Message-State: AOPr4FVkdgZ5zPEUUIjhkJgR5pwwnK63NrKc5u9oC0Y7r7EkdsPnTFBaTrIsLHGs/kMAnJzarORApAbb8gueyA== X-Received: by 10.194.205.134 with SMTP id lg6mr14865744wjc.153.1463991193799; Mon, 23 May 2016 01:13:13 -0700 (PDT) MIME-Version: 1.0 Sender: julienpauli@gmail.com Received: by 10.194.216.4 with HTTP; Mon, 23 May 2016 01:12:34 -0700 (PDT) In-Reply-To: References: <72f547d6-5fcf-3cd2-960d-cb612a429e47@php.net> Date: Mon, 23 May 2016 10:12:34 +0200 X-Google-Sender-Auth: mDTFrPX94dRmwO4TeOFW4RcCF04 Message-ID: To: Rasmus Schultz Cc: Rowan Collins , PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Exception::getLine() From: jpauli@php.net (Julien Pauli) On Sat, May 21, 2016 at 8:16 PM, Rasmus Schultz wrote: > Alright, so forget my comparison with other languages. > > My other points remain: > > Presently, "throw new" is treated as though it was one statement. > That's not the case. We have deferred throws and factory methods for > exceptions, and we have re-throws, so collecting the stack-trace at > construction time doesn't work. > > The construction site would only be relevant if "throw new" was in > deed a single statement. > > Recording the actual throw site is clearly the goal - the current > implementation is betting on "throw" and "new" happening at the same > site, which is merely circumstance. > > Ideally, an Exception should collect another stack trace for each > successive throw, which would enable you to trace not only the > original site, but the flow through any exception-handlers that might > have re-thrown the same Exception. > > As is, there is no information collected on throw, and thereby no > evidence or record of possible re-throws - on top of the fact that you > may be collecting and looking at bogus stack-traces from factory > methods or exception mappers. > > > On Fri, May 20, 2016 at 11:06 AM, Rowan Collins wrote: >> On 20/05/2016 08:22, Niklas Keller wrote: >>> >>> 2016-05-20 4:13 GMT+02:00 Jesse Schalken : >>>> >>>> The top frame is the construction (get_error) and the site of the throw >>>> (do_throw) doesn't appear in the stack at all. >>>> >>> >>> The comparison with JavaScript isn't a good one, since you can throw >>> everything in JS. If they didn't provide the stack trace upon throw, you >>> would not have a stack trace at all if you throw a plain string. >>> >> >> >> That explanation justifies completely the opposite behaviour to what Jesse >> described. >> >> According to MDN [1] the "stack" property is completley unstandardised, and >> some engines may indeed populate it on throw, but there's no hint on that >> page that they'll attach it to anything not constructed as an Error. >> >> So it's not a great comparison for either side (note that it was originally >> brought up by Rasmus as an example where it *does* come from the throw site) >> because the language doesn't actually guarantee you a stack trace at all. >> >> [1] >> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack >> >> Regards, >> -- >> Rowan Collins >> [IMSoP] >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > Hi. I explained that in my article detailing Exceptions from internal , http://jpauli.github.io/2015/04/09/exceptional-php.html I admit it would be more logical to collect the trace in the ZEND_THROW Opcode instead of in the create_handler of the Exception class. That would break backtraces, but we already broke them in PHP 7.0 So we could think about it for a 8.0 ideally , or a 7.1 ; I'm not sure. Anyway, that needs more debate ;-) Julien.Pauli