Skip to content

Conversation

@BCSharp
Copy link
Member

@BCSharp BCSharp commented Apr 27, 2025

This PR is relevant for hosting scenarios. Importing module signal in one IronPython engine registers a Ctrl+C signal handler, but it was not properly unregistered on engine shutdown. This means the handler was being referenced from the static System.Console (on Windows I suppose from the callback marshalling code) and caused a memory leak and interference with another later instance of the engine (at best).

The solution in this PR is to make PythonSignalState disposable and modify PythonContext that it recognizes disposable module states. For good measure I implemented a finalizer too although I think it will never (i.e before process termination) be called because without a call to Dispose() reference will stay alive and not being GC-ed.

Copy link
Contributor

@slozier slozier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@BCSharp BCSharp merged commit c6043a7 into IronLanguages:main Apr 29, 2025
17 checks passed
@BCSharp BCSharp deleted the signal_unregister branch April 29, 2025 20:28
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