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

Crashes on Windows #81

Open
gussen opened this issue Sep 20, 2022 · 9 comments
Open

Crashes on Windows #81

gussen opened this issue Sep 20, 2022 · 9 comments

Comments

@gussen
Copy link

gussen commented Sep 20, 2022

On Windows 10, 64-bit, GHC 8.10.7

If using formatting version 6.3.7 this small program works. It prints "Hello" and "Tre: 3".

{-# LANGUAGE OverloadedStrings #-}

module Main where

import qualified Formatting   as F
import  Formatting            ((%))

main :: IO ()
main = do
  putStrLn "Hello"
  F.fprint ("Tre: " % F.int) 3

If using formatting 7.0.0 or 7.1.3 it crashes. It doesn't write "Hello" or "Tre: 3".

@AJChapman
Copy link
Owner

This seems very surprising! Can you give any more information?

Is anyone else experiencing this problem?

@gussen
Copy link
Author

gussen commented Nov 21, 2022

Some more info

All versions runs in a REPL.

cabal repl
Resolving dependencies...
Build profile: -w ghc-8.10.7 -O1
In order, the following will be built (use -v for more details):

  • TestFormatting-0.1.0.0 (exe:TestFormatting) (configuration changed)
    Configuring executable 'TestFormatting' for TestFormatting-0.1.0.0..
    Preprocessing executable 'TestFormatting' for TestFormatting-0.1.0.0..
    GHCi, version 8.10.7: https://www.haskell.org/ghc/ :? for help
    [1 of 1] Compiling Main ( Main.hs, interpreted ) [Formatting changed]
    Ok, one module loaded.
    *Main> main
    Hello, Haskell!
    Tre: 3
    *Main> :q
    Leaving GHCi.

@gussen
Copy link
Author

gussen commented Nov 21, 2022

If using formatting 7.0.0 and GHC 8.10.7 this crashes without printing anything.

someFormatting :: IO ()
someFormatting = F.fprint ("Tre: " % F.int % "\n") (3::Int)

main :: IO ()
main = do
  putStrLn "Hello, Haskell!" 

@gussen
Copy link
Author

gussen commented Nov 21, 2022

If using GHC 9.2.5 on another computer it still ends without any output.
It doesn't matter if I build with -O1 or -O2.
If I build with a function that is using formatting, e.g.

someFormatting = F.fprint ("Tre: " % F.int % "\n") (3::Int)

It ends with no output even if I don't call the function.
If I remove the function from the program it works OK.

@gussen
Copy link
Author

gussen commented Nov 21, 2022

If trying to run the executable inside the debugger WinDbg I get this error: The application was unable to start correctly (0xc000007b).

@gussen
Copy link
Author

gussen commented Nov 21, 2022

If looking at the dependencies of the executable I can see that "libstdc++-6.dll" is a dependency when when building against formatting 7.0.0 and not when building with 6.3.7. I have many versions of that dll on my system so I copied "C:\ghcup\ghc\8.10.7\mingw\bin\libstdc++-6.dll" to the same directory as the built executable but it still didn't work.

@gussen
Copy link
Author

gussen commented Nov 21, 2022

If building formatting with 'no-double-conversion' set to True everything works fine.

@gussen
Copy link
Author

gussen commented Nov 21, 2022

I have now tested with double-conversion package and there is some strange linking problem. If using a MSYS2/MinGW64 shell I can get it to work on one of my machines. From Windows GUI or PowerShell it doesn't work. There are other reports of linking problems on Windows: https://gitlab.haskell.org/ghc/ghc/-/issues/20010.

@ysangkok
Copy link
Contributor

@gussen You mentioned GHC 9.2.x. Note that versions 9.2 and before of GHC had problems on Windows, which is why everything was rewritten to use Clang. See release notes:

A complete overhaul of GHC’s Windows support. This includes a migration to a fully Clang-based C toolchain, a deep refactoring of the linker, and many fixes in WinIO.

It might work better on GHC 9.4. Note that to use double-conversion on 9.4, you need to use it from git, since a compatible release wasn't yet released.

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

No branches or pull requests

3 participants