Fix #655: Async issues with threads outliving the chaiscript engine#656
Conversation
…revent heap-use-after-free Issues ChaiScript#632 and ChaiScript#636 (PRs ChaiScript#651 and ChaiScript#653) both stem from the same root cause: async threads spawned via async() can outlive the Dispatch_Engine, accessing shared state (global objects map, type maps) after it has been destroyed. The fix moves async() registration from the stdlib module into ChaiScript_Basic, where spawned threads are tracked via Dispatch_Engine. The engine's destructor now joins all outstanding async threads before destroying shared data structures. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@leftibot prior to this change, ChaiScript engine was copyable, but now it's not? |
|
Good question. The What this PR adds is the explicit That said, the explicit delete is still the right thing to do here since |
|
@leftibot update the code to follow the rule of 5 and explicitly =default the move operations then too |
Requested by @lefticus in PR ChaiScript#656 review. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Addressed review feedback from @lefticus. New commits: |
Automated fix by @leftibot.
What changed
Files
Closes #655
Triggered by @lefticus.