Skip to content

Remove an invalid free on nodeIDs - #173

Merged
MakisH merged 6 commits into
developfrom
fix-segfault
Aug 4, 2026
Merged

Remove an invalid free on nodeIDs#173
MakisH merged 6 commits into
developfrom
fix-segfault

Conversation

@MakisH

@MakisH MakisH commented Aug 4, 2026

Copy link
Copy Markdown
Member

After merging #146, I started getting segfaults at the end of the simulation, in PreciceInterface_FreeData. The new calls added with #146 were:

free(preciceInterface->elemIPID);
free(preciceInterface->elemIPCoordinates);
free(preciceInterface->nodeIDs);
free(preciceInterface->elementsMeshName);

The issue here is that nodeIDs is not allocated, but a reference to previously allocated memory. There are two possible fixes:

A. Make the reference a copy, as suggested by Lucia in the comment that is still there, or
B. remove the invalid free.

The solution to (A) would be:

- interface->nodeIDs = &sim->ialset[sim->istartset[interface->nodeSetID] - 1]; // Lucia: make a copy
+  interface->nodeIDs   = malloc(interface->numNodes * sizeof(ITG));
+  getElementsIDs(interface->nodeSetID, sim->ialset, sim->istartset, sim->iendset, interface->nodeIDs);

but, since the current version has been working fine so far, I suggest just removing the invalid free, and not to introduce an unnecessary copy.

@MakisH MakisH changed the title Fix segfault Remove an invalid free on nodeIDs Aug 4, 2026
@MakisH
MakisH merged commit 36e6d1e into develop Aug 4, 2026
4 checks passed
@MakisH
MakisH deleted the fix-segfault branch August 4, 2026 08:46
@MakisH MakisH added this to the v2.20.2 milestone Aug 5, 2026
@MakisH MakisH self-assigned this Aug 5, 2026
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.

1 participant