Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't attach finalizers to Handles in CommunicationHandle API #322

Merged
merged 1 commit into from
Aug 8, 2024

Conversation

sheaf
Copy link
Contributor

@sheaf sheaf commented Jul 25, 2024

We are now careful to not attach any finalizers to Handles when creating pipes for inter-process communication on Unix systems. Instead, the handles are closed manually.

The finalizers were causing problems in situations such as the following:

  • the parent creates a new pipe, e.g. pipe2([7,8]),
  • the parent spawns a child process, and lets FD 8 be inherited by the child,
  • the parent closes FD 8 (as it should),
  • the parent opens FD 8 for some other purpose, e.g. for writing to a file,
  • the finalizer for the Handle wrapping FD 8 runs, closing FD 8, even though it is now in use for a completely different purpose.

This PR does not include a test, as the above bug is a bit difficult to trigger. My reproducer for this bug was a test in the cabal-install testsuite; I can confirm that the bug no longer occurs with this patch.

This PR bumps the process version to 1.6.21.0. After releasing it on Hackage, I would also recommend deprecating 1.6.20.0.

We are now careful to not attach any Handle finalizers when creating
pipes for inter-process communication on Unix systems. Instead, the
handles are closed manually.

The finalizers were causing problems in situations such as the following:

  - the parent creates a new pipe, e.g. pipe2([7,8]),
  - the parent spawns a child process, and lets FD 8 be inherited by the child,
  - the parent closes FD 8 (as it should),
  - the parent opens FD 8 for some other purpose, e.g. for writing to a file,
  - the finalizer for the Handle wrapping FD 8 runs, closing FD 8, even though
    it is now in use for a completely different purpose.

This commit does not include a test, as the above bug is a bit difficult
to trigger.
@tomjaguarpaw
Copy link
Member

This seems sensible!

@bgamari
Copy link
Contributor

bgamari commented Aug 8, 2024

Yes, this seems like a reasonable approach.

@bgamari bgamari merged commit 302b43a into haskell:master Aug 8, 2024
41 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.

3 participants