Skip to content

Fix use after free in cell attack - #397

Closed
vincent-noel wants to merge 1 commit into
MathCancer:developmentfrom
sysbio-curie:fix/use-after-free
Closed

Fix use after free in cell attack #397
vincent-noel wants to merge 1 commit into
MathCancer:developmentfrom
sysbio-curie:fix/use-after-free

Conversation

@vincent-noel

@vincent-noel vincent-noel commented Dec 2, 2025

Copy link
Copy Markdown
Collaborator

Update

I updated this PR to only include cell attack, and updated the title accordingly.
Initially, when deleting a cell, I would look for all cells to see if it was a target of another cell, and if so clean the pAttackTarget.
I now modified the PR for cells to have a list of cells they are attacked by. That way, when deleting the cell, we know which cells we have to cleanup.
I think that together with #409 and #410, we have a good fix for the issues that this PR was initially tackling.

initial PR

I had some crash that I wanted to fix for a while, and finally found the issues:

  • pAttackTarget is not cleaned when the target is deleted, resulting in a use after free
  • neighbors are not always symmetrical, but when we delete a cell we suppose they are, resulting in a use after free
  • spring_attachments are not always symmetrical, but when we delete a cell we suppose they are, resulting in a use after free.

Here the fixes I'm proposing for now:

  • When deleting a cell, I check that no other cell has it as an attack target and remove it if so
  • When deleting a cell, after removing it from its known neighbors, check every cell to remove from unknown (non-symmetrical) neighbors
  • When deleting a cell, after removing it from its known spring_attachments, check every cell to remove from unknown (non-symmetrical) spring_attachments

Clearly, this can be improved, but it fixes the present issues.

Loading
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.

3 participants