Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Bug fix: Prevent intermediate state from appearing in final txlog #5048

Merged
merged 5 commits into from
Apr 26, 2022

Conversation

haltman-at
Copy link
Contributor

@haltman-at haltman-at commented Apr 23, 2022

Addresses #3884.

This PR fixes a problem where intermediate state -- specifically, the waitingForFunctionDefinition field -- was appearing in final txlogs. Why was this problem occurring? Basically, we had a case where the conditions for a jump out and for an identify were triggered on the same step. So an action was triggered for each, and, uh, I guess these things don't always work synchronously? IDK, I'm a little unclear on that point. Regardless, the jump out action deleted the waitingForFunctionDefinition intermediate state... and then the identify added it back in (setting it to false). Oops.

So, in order to prevent this from happening, I had to make the identify case exclusive of the other cases. Why wasn't it exclusive before? Well, what if we have a simultaneous jump-in and identify? When I wrote txlog, actually, I incorrectly thought that was the usual case. It isn't, and, well, how would that ever happen? You jump in, then you're on the function... simultaneous doesn't make sense.

In order to make sure we can handle that case, I also created combined jump-in/identify actions. This meant factoring the identification code a bit. Anyway so now jump-in w/o identify, identified-jump in, identify w/o jump-in are three exclusive cases using three different actions. (Five, actually, since jump-ins can be absorbed or not absorbed.) Rather than relying on two actions for the jump-in and identify case. (Not that I've seen any cases of this, but I want to be able to handle it.)

In order to make sure this problem doesn't crop up again, this PR also adds tests. Or rather, it adds to the existing tests, since the situation that was leading to the problem was among our existing tests already, so I didn't create any new tests. Rather, I just added to all of the existing tests a check that there's no intermediate state left at the end. And that's it!

This'll cause merge conflicts with #4882, I'm sure. :-/ Also: prettier made a bunch of changes on this PR. Sorry.

@cds-amal
Copy link
Member

cds-amal commented Apr 25, 2022

Basically, we had a case where the conditions for a jump out and for an identify were triggered on the same step. So an action was triggered for each, and, uh, I guess these things don't always work synchronously?

Wow

Still, in order to make sure we can handle that case, I also created combined jump-in/identify actions. This meant factoring the identification code a bit. Anyway so now jump-in w/o identify, identified-jump in, identify w/o jump-in are three exclusive cases using three different actions. (Five, actually, since jump-ins can be absorbed or not absorbed.) Rather than relying on two actions for the jump-in and identify case. (Not that I've seen any cases of this, but I want to be able to handle it.)

Nice solution!

Copy link
Member

@cds-amal cds-amal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it @haltman-at. Excited to see this merged in!

if (!modifiedNode.arguments) {
modifiedNode.arguments = variables;
}
if (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit. I was confused if the comments on 39-40 applied to this block of code. It seems it doesn't. A blank line, or a new comment, could help the reader.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it does apply, actually?

Copy link
Member

@cds-amal cds-amal Apr 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. I highlighted the wrong block. It was this snippet of code that didn't reference a null or undefined that didn't relate to the comment.

+    if (
+      modifiedNode.type === "callexternal" &&
+      modifiedNode.kind === "library"
+    ) {
+      modifiedNode.kind = "function";
+      delete modifiedNode.data;
+    }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. Yeah, I can clarify that.

packages/debugger/test/txlog.js Show resolved Hide resolved
@haltman-at
Copy link
Contributor Author

Basically, we had a case where the conditions for a jump out and for an identify were triggered on the same step. So an action was triggered for each, and, uh, I guess these things don't always work synchronously?

Wow

Yeah I'm pretty confused about this TBH. It seems like sometimes it works fine and sometimes it doesn't? This is hardly the first time I've run into this problem with multiple actions... and yet there to be other cases where it's fine? I have to admit I don't really understand this.

@haltman-at
Copy link
Contributor Author

Still, in order to make sure we can handle that case, I also created combined jump-in/identify actions. This meant factoring the identification code a bit. Anyway so now jump-in w/o identify, identified-jump in, identify w/o jump-in are three exclusive cases using three different actions. (Five, actually, since jump-ins can be absorbed or not absorbed.) Rather than relying on two actions for the jump-in and identify case. (Not that I've seen any cases of this, but I want to be able to handle it.)

Nice solution!

Well, uh, I ended up removing this as unnecessary... see above.

Copy link
Member

@cds-amal cds-amal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants