haskell / win32

Haskell support for the Win32 API
http://hackage.haskell.org/package/Win32
Other
97 stars 62 forks source link

"Pattern match failure in do expression at libraries\Win32\System\Win32\Types.hsc:311:9-15" #177

Closed hasufell closed 3 years ago

hasufell commented 3 years ago

When running the test suite of temporary-1.3 with --io-manager=native I get the error above:

Test suite test: RUNNING...
test.exe: user error (Pattern match failure in do expression at libraries\Win32\System\Win32\Types.hsc:311:9-15)
Test suite test: FAIL
Test suite logged to: C:\Users\hasuf\temporary\dist-newstyle\build\x86_64-windows\ghc-9.0.1\temporary-1.3\t\test\test\temporary-1.3-test.log

Steps to Reproduce (for bugs)

  1. Run the test suite with new IO manager

Your Environment

cabal-install 3.4.0.0, GHC-9.0.1, Win32-2.10.0.0, Windows 10

Mistuke commented 3 years ago

Hmm that looks like a program or configuration error. You've somehow ended up in withHandleToHANDLEPosix that's a program bug. Posix handles aren't defined in WinIO.

Since temporary does not have a dependency on Win32 the issue must be in one of it's dependencies. It looks like something is either calling withHandleToHANDLEPosix or is calling withHandleToHANDLE on a version of Win32 without WinIO support.

hasufell commented 3 years ago

It's depending on base: https://gitlab.haskell.org/ghc/ghc/-/blob/3d5cb3352c1e1c20f0d5de427f4edbc765ce06d6/libraries/base/System/IO.hs#L500

Mistuke commented 3 years ago

I do not follow. Base doesn't call into Win32 to create handles. It has its own routines to do so.

The code in base handles the IO manager switch itself

findTempName = findTempNamePosix <!> findTempNameWinIO

And does not enter the posix code. If it did the compiler wouldn't bootstrap and nothing using WinIO would work.

Mistuke commented 3 years ago

Turns out it is a Win32 bug, a typo has caused the CPP macro to go missing in the one place that wouldn't cause a build failure.

I'll do some backport tomorrow to make a 2.10.0.1 which cabal should be able to use for a fix.

hasufell commented 3 years ago

nice find