Skip to content

Fix some memory errors#304

Merged
pjaaskel merged 3 commits intocpc:mainfrom
gtkiku:mem-errors
Feb 11, 2026
Merged

Fix some memory errors#304
pjaaskel merged 3 commits intocpc:mainfrom
gtkiku:mem-errors

Conversation

@gtkiku
Copy link
Contributor

@gtkiku gtkiku commented Feb 10, 2026

32d14cd and fa05296 are small and hopefully self-explanatory.

007342d is a bit more interesting, the previous implementation of a timeout thread checked for some object member variables to decide if the simulator should be stopped or not, but didn't account for situations where a long-running program starts a TTA simulation and then destroys the simulator object. If the program stays alive longer than the timeout, the timeout thread wakes up and tries to access the simulator object that it was started from, which is long gone by now. The fix here is to kill the timeout thread when we know that we won't be needing it anymore. Adds a bit of boilerplate which could potentially be minimized by a lambda or something but the impact is small enough that I thought it would be more clear if I just leave it as is.

+ Previous version would potentially access freed regions
+ Returned the char* buffer owned by a temporary string that was being
  freed by the return
+ Valgrind was flagging the manual `delete` as being of mismatched size
@gtkiku gtkiku requested a review from pjaaskel February 10, 2026 14:41
@pjaaskel pjaaskel merged commit 616d2af into cpc:main Feb 11, 2026
1 check 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.

2 participants