Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix UnitBox memory leak in UCE #1655

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

tim-hoffman
Copy link
Member

No description provided.

@linghuiluo
Copy link
Member

@swissiety can you review this?


// Assert that the set of boxes obtained from all units equals the set
// obtained by checking Unit#getBoxesPointingToThis() on all units.
Assert.assertEquals(new HashSet<>(getAllUnitBoxes(body)), new HashSet<>(getAllBoxesPointingToUnits(body)));
Copy link
Collaborator

Choose a reason for hiding this comment

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

please assert that the transformer changed sth i.e. removed the trap

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

Comment on lines +105 to +108
UnitBox beginBox = trap.getBeginUnitBox();
UnitBox endBox = trap.getEndUnitBox();
UnitBox handlerBox = trap.getHandlerUnitBox();
if ((beginBox.getUnit() == endBox.getUnit()) || !reachable.contains(handlerBox.getUnit())) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

please restructure the UnitBox assignments inside the if block so the assignments are just executed when needed

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think any improvement can be made. The first two (beginBox and endBox) will always be used since they are in the first condition. The final variable (handlerBox) will always be used as well. If the first condition is true, it will be used inside the if statement body and if the first condition is false, it will be used in the second condition (and possibly again inside the body).

This ensures the trap was actually removed as expected. Also, rename the test method to something more meaningful.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants