Fix intermittent double-free crash in IBM_Cylinder (PointLinkedList)#83
Draft
Copilot wants to merge 2 commits into
Draft
Fix intermittent double-free crash in IBM_Cylinder (PointLinkedList)#83Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
Copilot created this pull request from a session on behalf of
loganoz
June 26, 2026 12:13
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a non-deterministic double-free crash in the IBM_Cylinder CI path by fixing PointLinkedList bookkeeping and making PointLinkedList_Destruct free nodes safely based on an accurate node count.
Changes:
- Initialize
PointLinkedList%NumOfPointsto0in the list constructor. - Maintain
NumOfPointscorrectly on add/remove operations. - Rework
PointLinkedList_Destructto deallocate all nodes without dereferencing freed memory, and nullifyheadon exit.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
391
to
+395
| end if | ||
|
|
||
| nullify(current, currentNext) | ||
|
|
||
| this% NumOfPoints = this% NumOfPoints + 1 |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
IBM_CylinderCI test failed non-deterministically withfree(): double free detected in tcache 2→ SIGABRT insidePointLinkedList_Destruct, called fromConvexHull→OBB_construct→IBM_construct.Root cause
PointLinkedListinTessellationTypes.f90maintained aNumOfPointscounter that was never initialized and never updated by any list operation. The destructor used this garbage value to drive its deallocation loop:Which outcome occurred depended on what happened to be in that memory location, explaining the intermittent failure.
A secondary bug: the original destructor loop (
do i = 2, NumOfPoints) freed only N−1 nodes, always leaking the last one, and on its final iteration readcurrent%nextfrom already-freed memory.Changes (
TessellationTypes.f90)PointLinkedList_Construct— initializeNumOfPoints = 0PointLinkedList_Add— incrementNumOfPointsafter insertionPointLinkedList_RemoveLast— decrementNumOfPointsafter removalPointLinkedList_Remove— decrementNumOfPointsafter removalPointLinkedList_Destruct— restructure loop to free all N nodes without reading from freed memory; nullifyheadon both exit paths