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(memory): prevent double destruction in AnyVector::swapMove #1358

Merged
merged 1 commit into from
Nov 16, 2024

Conversation

RiscadoA
Copy link
Member

@RiscadoA RiscadoA commented Nov 5, 2024

Description

This happened only when the last element of an AnyVector was removed in a swapMove.
The destructor of the last element was called in the swapMove itself, and once again on pop.
So, simply moved the extra destructor call to within the if itself.

Checklist

  • Self-review changes.
  • Add entry to the changelog's unreleased section.

@RiscadoA RiscadoA added this to the 0.5 milestone Nov 5, 2024
@RiscadoA RiscadoA self-assigned this Nov 5, 2024
@RiscadoA RiscadoA requested a review from a team as a code owner November 5, 2024 13:46
Copy link
Contributor

github-actions bot commented Nov 5, 2024

PR Preview Action v1.4.8
🚀 Deployed preview to https://GameDevTecnico.github.io/cubos/preview/pr-1358/
on branch gh-pages at 2024-11-16 15:48 UTC

@RiscadoA RiscadoA requested review from a team, roby2014, luishfonseca and Dageus and removed request for a team November 5, 2024 13:51
Copy link

codecov bot commented Nov 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 41.95%. Comparing base (45402c0) to head (05583bc).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1358   +/-   ##
=======================================
  Coverage   41.95%   41.95%           
=======================================
  Files         441      441           
  Lines       33115    33115           
  Branches     3870     3870           
=======================================
  Hits        13893    13893           
  Misses      19222    19222           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@RiscadoA RiscadoA requested review from a team, diogomsmiranda, Dageus and RodrigoVintem and removed request for Dageus, roby2014, luishfonseca and a team November 5, 2024 14:04
Copy link
Contributor

@diogomsmiranda diogomsmiranda left a comment

Choose a reason for hiding this comment

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

Seems simple enough! If only all bugs were solved with a line change...

@diogomsmiranda
Copy link
Contributor

Although one thing I notice now is why do we have assertions in the middle of srccode? Shouldn't we have tests with those instead?

@RiscadoA
Copy link
Member Author

RiscadoA commented Nov 8, 2024

Although one thing I notice now is why do we have assertions in the middle of srccode? Shouldn't we have tests with those instead?

They're just sanity checks, it's good practice to write all assumptions of the code in assertions 😌

@RiscadoA RiscadoA enabled auto-merge (rebase) November 9, 2024 07:56
This happened only when the last element of an AnyVector was removed in
a swapMove.
The destructor of the last element was called in the swapMove itself,
and once again on pop.
@RiscadoA RiscadoA merged commit ddb18ac into main Nov 16, 2024
9 checks passed
@RiscadoA RiscadoA deleted the ecs-double-free branch November 16, 2024 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants