Skip to content

fix(es/transforms): Fix capacity overflow with decorators #8815

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

Merged
merged 4 commits into from
Apr 4, 2024

Conversation

dsherret
Copy link
Contributor

@dsherret dsherret commented Apr 4, 2024

Description: Fixes an incorrect capacity (found while investigating a segfault).

More details: denoland/deno#23187 (comment)

Related issue (if exists): None

@dsherret dsherret requested a review from a team as a code owner April 4, 2024 12:47
Copy link

changeset-bot bot commented Apr 4, 2024

⚠️ No Changeset found

Latest commit: e19b656

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -1699,7 +1699,8 @@ impl VisitMut for Decorator202203 {
let old_extra_lets = self.extra_lets.take();
let old_extra_vars = self.extra_vars.take();

let mut new = Vec::with_capacity(n.len());
Copy link
Contributor Author

@dsherret dsherret Apr 4, 2024

Choose a reason for hiding this comment

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

Looking into it more, I think the segfault is caused by the use of an Arena. The value it's providing here for .len() is crazy high. I opened #8816

Edit: not sure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kdy1 do you have any idea why this n.len() might sometimes be returning a very large 1314431791570856 / sizeof(Stmt)? We noticed it only after bumping to the latest swc patches in only some scenarios denoland/deno#23187 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

Cqn you try reverting dudykr/ddbase#27 ?
You can clone it and add [patch.crates.io] to the local clone. cc @bgw

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! It was actually locked to 0.2.6. I'll try 0.2.8 and see.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same issue in 0.2.8 as in 0.2.6. I'll try harder tomorrow on getting a local reproduction so that I can isolate the problem. It only seems to happen on the CI atm for some reason.

Copy link

Choose a reason for hiding this comment

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

This is definitely a corruption bug -- do these two 32-bit numbers look familiar? Indices perhaps?

>>> hex(1314431791570856)
'0x4ab7800049fa8'
>>> [0x49fa8, 0x4ab78]
[303016, 306040]

@dsherret dsherret marked this pull request as draft April 4, 2024 13:59
dsherret added 2 commits April 4, 2024 10:35
@dsherret dsherret marked this pull request as ready for review April 4, 2024 14:53
Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

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

swc-bump:

  • swc_ecma_transforms_proposal
  • swc_ecma_utils

@kdy1 kdy1 added this to the Planned milestone Apr 4, 2024
@kdy1 kdy1 self-assigned this Apr 4, 2024
@kdy1 kdy1 changed the title fix: capacity overflow with decorators fix(es/transforms): Fix capacity overflow with decorators Apr 4, 2024
@kdy1 kdy1 merged commit 974f5c7 into swc-project:main Apr 4, 2024
142 checks passed
@dsherret dsherret deleted the fix_capacity_decorators branch April 5, 2024 00:26
@kdy1 kdy1 modified the milestones: Planned, v1.4.13 Apr 9, 2024
@swc-project swc-project locked as resolved and limited conversation to collaborators May 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants