Skip to content

Use base's hDuplicateTo; drop the patched copy - #5117

Merged
VeryMilkyJoe merged 1 commit into
haskell:masterfrom
dschrempf:dom/ghcide/drop-hduplicateto-copy
Oct 10, 2026
Merged

VeryMilkyJoe merged 1 commit into
haskell:masterfrom
dschrempf:dom/ghcide/drop-hduplicateto-copy

Conversation

@dschrempf

@dschrempf dschrempf commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Development.IDE.GHC.Util.hDuplicateTo' is a copy of base's hDuplicateTo without the hClose_help on the target handle. Closing the descriptor before dup2 let another thread reuse the number, and dup2 failed with EBUSY (haskell/ghcide#259). The issue was fixed upstream many years ago ("Avoid race condition in hDuplicateTo"; ghc/ghc!2318; since GHC 9.0.1).

The copy in HLS was strictly worse than base: its DuplexHandle case still called hClose_help.

This PR:

  • replaces the call in defaultArguments with GHC.IO.Handle.hDuplicateTo;
  • removes hDuplicateTo' and its copied helpers (dupHandleTo, dupHandle_, ioe_dupHandlesNotCompatible).

hDuplicateTo' is no longer exported from Development.IDE.GHC.Util or Development.IDE. It wasn't used by anything else in HLS.


@dschrempf
dschrempf requested a review from wz1000 as a code owner October 9, 2026 15:43

@VeryMilkyJoe VeryMilkyJoe left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good, thank you!

`hDuplicateTo'` copied base's `hDuplicateTo` without its `hClose_help` on
the target: closing the descriptor before `dup2` let another thread reuse
it, and `dup2` failed with `EBUSY`. Base fixed this in GHC 9.0.1 ("Avoid
race condition in hDuplicateTo", ghc/ghc!2318); all supported GHC versions
carry the fix. The copy's `DuplexHandle` case still closed the target.

Removes `hDuplicateTo'` from the API of `Development.IDE.GHC.Util` and
`Development.IDE`.
@VeryMilkyJoe
VeryMilkyJoe force-pushed the dom/ghcide/drop-hduplicateto-copy branch from 6f507e8 to 8c18ca6 Compare October 10, 2026 12:55
@VeryMilkyJoe
VeryMilkyJoe enabled auto-merge (squash) October 10, 2026 12:56
@VeryMilkyJoe
VeryMilkyJoe merged commit cd88104 into haskell:master Oct 10, 2026
42 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.

2 participants