Skip to content

Add rule-of-five to GFrameDataCollection to prevent double-free#168

Merged
maureeungaro merged 1 commit into
gemc:mainfrom
zhaozhiwen:fix/136-frame-rule-of-five
Jun 13, 2026
Merged

Add rule-of-five to GFrameDataCollection to prevent double-free#168
maureeungaro merged 1 commit into
gemc:mainfrom
zhaozhiwen:fix/136-frame-rule-of-five

Conversation

@zhaozhiwen

Copy link
Copy Markdown
Collaborator

GFrameDataCollection owns three raw pointers (gevent_header, the payload objects, and the heap-allocated payload vector) and deletes them in its destructor, but declared no copy/move operations. The implicitly generated copy/move do a shallow pointer copy, so any copy (stored by value, passed by value, returned pre-elision) would give two owners and double-free on destruction.

No active copy site exists today, so this is a latent footgun. Delete copy and move to make the ownership intent explicit and close the hole; the documented long-term fix is unique_ptr members.

Validation: rebuilt gemc in the Geant4 11.4.1 dev container — the deletions compile cleanly, confirming nothing currently copies or moves it.

Fixes #136

GFrameDataCollection owns three raw pointers (gevent_header, the payload
objects, and the heap-allocated payload vector) and deletes them in its
destructor, but declared no copy/move operations. The implicitly
generated copy/move do a shallow pointer copy, so any copy (stored by
value, passed by value, returned pre-elision) would give two owners and
double-free on destruction.

No active copy site exists today, so this is a latent footgun. Delete
copy and move to make the ownership intent explicit and close the hole;
the documented long-term fix is unique_ptr members. Verified the
deletions don't break the build (nothing copies or moves it).

Fixes gemc#136

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@maureeungaro maureeungaro merged commit 12b556a into gemc:main Jun 13, 2026
30 checks passed
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.

[Low] Add rule-of-five to GFrameDataCollection to prevent double-free if copied

2 participants