From: deivid.rodriguez@... Date: 2019-07-31T10:51:50+00:00 Subject: [ruby-core:94071] [Ruby master Feature#15912] Allow some reentrancy during TracePoint events Issue #15912 has been updated by deivid (David Rodr�guez). Hi Koichi! Thanks for answering. So, you mean to allow the reentrancy (TracePoint events being triggered from inside TracePoint handlers) if the TracePoint API user requests so? I guess that would work, I could call `tp.reopen {}` before giving a prompt to the byebug user, so that zeitwerk events will trigger. I wonder though whether it's better that this _just works_ when it could work, and it ignores events when they would cause an infinite loop. I think my suggestion of keeping a stack of events being handled would allow that and would require no additions to the API. ---------------------------------------- Feature #15912: Allow some reentrancy during TracePoint events https://bugs.ruby-lang.org/issues/15912#change-80301 * Author: deivid (David Rodr�guez) * Status: Assigned * Priority: Normal * Assignee: ko1 (Koichi Sasada) * Target version: ---------------------------------------- I got a report in byebug about byebug being incompatible with zeitwerk. This one: https://github.com/deivid-rodriguez/byebug/issues/564. This is a problem because zeitwerk is the default Rails code loader, and byebug is the default Rails debugger. Both of these tools rely on the TracePoint API: * Byebug uses a bunch of TracePoint events to stop execution at certain points in your program. * Zeitwek uses `:class` events to be able to resolve some circular edge cases. I investigated the problem and I think the issue is that while stopped at the byebug prompt, we're actually in the middle of processing a TracePoint event. That means that further TracePoint events triggered at the byebug's prompt will be ignored, because otherwise we could get into an infinite loop where the handling of events would trigger more events that trigger themselves the execution of handlers again. I understand why the TracePoint API does this, but if we could allow some level of reentrancy here, we could probably make these tools play nice together. I figure if we kept a stack of TracePoint event handlers being run, and check that the current event type is not already in the stack, we would allow :class events to be triggered from :line events, and I think that would allow Zeitwerk to work within byebug. What do you think about this, @ko1? -- https://bugs.ruby-lang.org/ Unsubscribe: