Internal error running FFI interpreter on Visual Studio
Summary
When in a C++ project using an FFIInterpreter.dll
based on Phyx's example in Stack Overflow (https://stackoverflow.com/questions/8646247/writing-haskell-interpreter-in-c-using-ghc-or-hugs-as-library), GHC 9.0.1 throws the following internal error:
ghcDll: internal error: IMAGE_REL_AMD64_ADDR32[NB]: High bits are set in 1736bf4c7d1 for ghczmprim_GHCziTypes_ZMZN_closure
(GHC version 9.0.1 for x86_64_unknown_mingw32)
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
Error occurs only when in Visual Studio (in my case 2019, haven't tried other versions). It compiles fine but throws this error in runtime in createContext
. When using GHC command line (ghc -no-hs-main -o tester .\main.cpp .\FFIInterpreter.lib
) everything works fine. Have tried compiling DLL with -fexternal-interpreter
but to no avail.
Steps to reproduce
- Clone https://github.com/allanschottler/reproduce_ghc_internal_error.git
- Make sure GHC_HOME is set.
- Open Visual Studio solution, compile and run.
Expected behavior
Should run Test.hs
and output correct result.
Environment
- GHC version used: 9.0.1
- Operating System: Windows 10
- System Architecture: 64bits