Skip to content

Error with most TH on mingwW64 on GHC 9.4 and 9.6 #1913

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

Closed
amesgen opened this issue Apr 10, 2023 · 4 comments
Closed

Error with most TH on mingwW64 on GHC 9.4 and 9.6 #1913

amesgen opened this issue Apr 10, 2023 · 4 comments
Assignees
Labels
bug Something isn't working wontfix

Comments

@amesgen
Copy link
Member

amesgen commented Apr 10, 2023

Describe the bug

Reading files during TH (e.g. via file-embed) (EDIT: this is just an example, also happens with much more mundane things, see #1913 (comment)) fails when cross-compiling to mingwW64 from x86_64-linux on GHC 9.4 and 9.6.

main :: IO ()
main = putStrLn $(TH.lift =<< TH.runIO (readFile "app/foo.txt"))

Steps To Reproduce

Minimal reproducible example: https://github.com/amesgen/stuff/tree/haskell.nix-mingwW64-TH-readFile-again

Concretely:

 $ nix build github:amesgen/stuff/haskell.nix-mingwW64-TH-readFile-again#ghc944
...
/nix/store/f1yzg91kr20alxcpqwikxwv708irs7xi-iserv-wrapper/bin/iserv-wrapper: line 31:   200 Segmentation fault      (core dumped) WINEDLLOVERRIDES="winemac.drv=d" WINEDEBUG=warn-all,fixme-all,-menubuilder,-mscoree,-ole,-secur32,-winediag WINEPREFIX=$TMP /nix/store/90hdb8v389sxv4xbxgv80w36lfbg1c78-wine-5.4/bin/wine64 $REMOTE_ISERV/iserv-proxy-interpreter.exe tmp $PORT
app/Main.hs:8:17: error:
    • Exception when trying to run compile-time code:
        ghc-iserv terminated (1)
      Code: (TH.lift =<< TH.runIO (readFile "app/foo.txt"))
    • In the untyped splice:
        $(TH.lift =<< TH.runIO (readFile "app/foo.txt"))
  |
8 | main = putStrLn $(TH.lift =<< TH.runIO (readFile "app/foo.txt"))
  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Full logs

 $ nix build github:amesgen/stuff/haskell.nix-mingwW64-TH-readFile-again#ghc961
...
iserv-proxy-interpreter.exe: Could not load Object Code /nix/store/xg4301nc9ygcpkpw8d5rp0wr81n299p6-x86_64-w64-mingw32-ghc-9.6.1/lib/x86_64-windows-ghc-9.6.1/ghc-prim-0.10.0/HSghc-prim-0.10.0.o.
<no location info>: error: unable to load unit `ghc-prim-0.10.0'

Full logs

Expected behavior

It should compile fine, as it does e.g. on 9.2.

 $ nix build github:amesgen/stuff/haskell.nix-mingwW64-TH-readFile-again#ghc927 # works fine

Additional context

Maybe it is again due to a Wine version problem, cf. #1487?

@amesgen amesgen added the bug Something isn't working label Apr 10, 2023
@amesgen
Copy link
Member Author

amesgen commented Apr 10, 2023

Actually, this is not specific to reading files; similar errors occur with much more trivial TH, e.g. one gets similar errors as soon as the library depends on the text library, even if it is not imported anywhere and the TH is entirely trivial such as

main = putStrLn $ show $(TH.lift (1 :: Int))

So something about TH seems to be very broken for mingwW64.

EDIT: At least the text deficiency is already known:

# TH breaks for ghc 9.4.3 cross compile for windows if the library even
# just depends on the `text` package (this may be related to the C++ dependency).

The original issue (in particular the MRE) is independent of this though.

@amesgen amesgen changed the title Error when reading files via TH on mingwW64 on GHC 9.4 and 9.6 Error with most TH on mingwW64 on GHC 9.4 and 9.6 Apr 10, 2023
@hamishmack hamishmack self-assigned this May 5, 2023
@stale
Copy link

stale bot commented Sep 2, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Sep 2, 2023
@amesgen
Copy link
Member Author

amesgen commented Sep 6, 2023

AFAICT this is currently being worked on in #2034

@amesgen
Copy link
Member Author

amesgen commented Sep 8, 2023

This was indeed fixed in #2034, but one sometimes has to use reinstallableLibGhc = false;, otherwise one still gets weird segfaults:

---> Starting iserv-proxy-interpreter.exe on port 5528
---| iserv-proxy-interpreter.exe should have started on 5528
0048:err:systray:initialize_systray Could not create tray window
008c:err:setupapi:SetupDefaultQueueCallbackW copy error 1812 L"@C:\\windows\\system32\\drivers\\wineusb.sys,-1" -> L"C:\\windows\\inf\\wineusb.inf"
wine: failed to open L"C:\\windows\\syswow64\\rundll32.exe": c0000135
wine: configuration in L"/build" has been updated.
�[?25lListening on port 5528
�[?25h0024:err:seh:call_stack_handlers invalid frame 00007FFFFF68EF38 (0000000000022000-0000000000220000)
0024:err:seh:NtRaiseException Exception frame is not in stack limits => unable to dispatch exception.
iserv-proxy: <socket: 6>: hGetBufSome: resource vanished (Connection reset by peer)

�[;1m<no location info>: �[;1m�[31merror�[0m�[0m�[;1m:�[0m�[0m�[;1m ghc-iserv terminated (1)�[0m�[0m

Will close this issue now, but if I or someone else encounters a situation where reinstallableLibGhc = false; is infeasible, it might make sense to open a separate issue for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix
Projects
None yet
Development

No branches or pull requests

2 participants