From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 472421F731 for ; Sat, 10 Aug 2019 15:54:58 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 4B8571209EF; Sun, 11 Aug 2019 00:54:51 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id D4A42120972 for ; Sun, 11 Aug 2019 00:54:48 +0900 (JST) Received: by filter0092p3mdw1.sendgrid.net with SMTP id filter0092p3mdw1-26471-5D4EE8CB-2C 2019-08-10 15:54:51.623013905 +0000 UTC m=+1163522.441124034 Received: from herokuapp.com (unknown [184.73.128.125]) by ismtpd0066p1mdw1.sendgrid.net (SG) with ESMTP id qlBBZYATS0audF21M-VZ2w for ; Sat, 10 Aug 2019 15:54:51.557 +0000 (UTC) Date: Sat, 10 Aug 2019 15:54:51 +0000 (UTC) From: deivid.rodriguez@riseup.net Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 69796 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15912 X-Redmine-Issue-Author: deivid X-Redmine-Issue-Assignee: ko1 X-Redmine-Sender: deivid X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?klzXTY0v3jOvaMSihdVenmzxCeXPrK4t1AV7GwiE8Tg=2FSkwAA+JJ2oNLJyOiQI?= =?us-ascii?Q?tXTMC=2FzbPUd7vDpNFRZWnzCp6RFGBOdb5lUr3gO?= =?us-ascii?Q?pwQq8+jWeM+uEw+sbf94EWJG1bofvqNtWmZMz76?= =?us-ascii?Q?pVoWePJd9IvWvmeIQ=2Fzc=2FX=2FsRkA0hGZN7A9zyLT?= =?us-ascii?Q?UzatWM2CQ=2FUQRAgGKgQC6W0NYK0RvWsB=2FgQ=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 94251 Subject: [ruby-core:94251] [Ruby master Feature#15912] Allow some reentrancy during TracePoint events X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #15912 has been updated by deivid (David Rodr=EDguez). Regarding your questions, `reopen` would work for me, and regarding passing= events, I think a list of the events to be reopened like `TracePoint.new(*= events)` would work. If I understand what you are proposing, we would be giving full control to = the user, and allowing it to cause infinite loops. For example, if I call `= tp.reopen(:line)` during the execution of a `:line` event, I would get an i= nfinite loop. I still feel that a "just works" solution should be possible, even for hand= lers of the same type. Say we have `line_handler1`, and `line_handler2` reg= istered for `:line` events. Currently, when a `:line` event fires, we run h= andlers sequentially without allowing other events to fire during their exe= cution. We could relax this restriction so that `:line` events could fire u= nless they're currently being handled, so that during execution of `line_ha= ndler1`, = `:line` events could fire and run `line_handler2`. ``` -> Main program execution starts -> Line event fired -> Execution of line_handler1 starts -> Line event fired -> Execution of line_handler2 starts -> Line event fired -> Line event fired -> ... -> Execution of line handler2 ends -> Line event fired -> Execution of line_handler2 starts -> Line event fired -> Line event fired -> ... -> Execution of line handler2 ends -> ... -> Execution of line_handler1 ends -> ... -> Main program ends ``` ---------------------------------------- Feature #15912: Allow some reentrancy during TracePoint events https://bugs.ruby-lang.org/issues/15912#change-80566 * Author: deivid (David Rodr=EDguez) * Status: Assigned * Priority: Normal * Assignee: ko1 (Koichi Sasada) * Target version: = ---------------------------------------- I got a report in byebug about byebug being incompatible with zeitwerk. Thi= s one: https://github.com/deivid-rodriguez/byebug/issues/564. This is a pro= blem because zeitwerk is the default Rails code loader, and byebug is the d= efault Rails debugger. Both of these tools rely on the TracePoint API: * Byebug uses a bunch of TracePoint events to stop execution at certain poi= nts in your program. * Zeitwek uses `:class` events to be able to resolve some circular edge cas= es. I investigated the problem and I think the issue is that while stopped at t= he byebug prompt, we're actually in the middle of processing a TracePoint e= vent. That means that further TracePoint events triggered at the byebug's p= rompt will be ignored, because otherwise we could get into an infinite loop= where the handling of events would trigger more events that trigger themse= lves the execution of handlers again. I understand why the TracePoint API does this, but if we could allow some l= evel of reentrancy here, we could probably make these tools play nice toget= her. I figure if we kept a stack of TracePoint event handlers being run, an= d check that the current event type is not already in the stack, we would a= llow :class events to be triggered from :line events, and I think that woul= d allow Zeitwerk to work within byebug. What do you think about this, @ko1? -- = https://bugs.ruby-lang.org/ Unsubscribe: