Skip to content

Unboxed tuple error when importing a module with no-specialise #771

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
michaelpj opened this issue Jun 24, 2020 · 12 comments
Closed

Unboxed tuple error when importing a module with no-specialise #771

michaelpj opened this issue Jun 24, 2020 · 12 comments
Labels
component: ghcide status: needs info Not actionable, because there's missing information type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@michaelpj
Copy link
Collaborator

I have modules A and B. A imports B, and B has OPTIONS_GHC -fno-specialise. ghcide gives me the following error on A (but not B). The error goes away if I remove the no-specialise on B.

  Program error: Error: bytecode compiler can't handle unboxed tuples and sums.
  Possibly due to foreign import/export decls in source.
  Workaround: use -fobject-code, or compile this module to .o separately.

I remembered this because I saw Ben Gamari report something similar on IRC, not sure if it's the same.

@michaelpj
Copy link
Collaborator Author

I think worker/wrapper can produce unboxed tuples, which will probably usually be specialized away. So I can see how this would happen if we're not compiling B with reduced enough optimization settings to prevent that.

@pepeiborra
Copy link
Collaborator

Just for my understanding, do either B or A contain any TH?

ghcide is certainly trying to disable optimisation, but maybe the setting is getting overridden later on:

https://github.com/digital-asset/ghcide/blob/21161389842a3141f82c82a6757d6eadfb264e8b/exe/Main.hs#L666

@michaelpj
Copy link
Collaborator Author

michaelpj commented Jun 24, 2020

They both do. Not sure if it matters!

@pepeiborra
Copy link
Collaborator

They do. Not sure if it matters!

Why would ghcide go through the trouble of generating byte code otherwise?

@ndmitchell
Copy link
Collaborator

So hypothesis is we compile the module to byte code to generate TH. But something interferes and turns the optimisation up sufficiently high that the bytecode contains unboxed tuples? @michaelpj - do you have any -O2 or similar pragmas either in files, or in the Cabal/Stack from which you build? If so, does removing those and restarting fix it?

@michaelpj
Copy link
Collaborator Author

Not AFAICT. I'll experiment some more and see if anything affects it.

One thing I tried to try and pin it down:

  • Set optimization: 0 in cabal.project
  • Load the module up in cabal repl

That works fine, which I would have thought corresponds to the ghcide situation.

@ndmitchell
Copy link
Collaborator

Ghcide and Cabal Repl are about a million miles apart nowadays - entirely feasible for it to work with one but not the other. Is it likely we can get a minimal reproducer?

@michaelpj
Copy link
Collaborator Author

Sure, I just wanted to establish that it's not Totally Broken but only broken in ghcide (and therefore plausible that this is a bug rather than me making a mistake).

I'll try and boil this down, not sure when I'll get to it.

@michaelpj
Copy link
Collaborator Author

Okay, I definitely need to boil this down, it seems to be non-deterministic too :(

@michaelpj
Copy link
Collaborator Author

Which probably invalidates my claim that removing no-specialise helps!

@ndmitchell
Copy link
Collaborator

If you can reproduce this on the command line with ghcide running on a file without an IDE that would be easier to debug - might be easier to reduce as well.

@pepeiborra pepeiborra transferred this issue from haskell/ghcide Dec 31, 2020
@jneira jneira added component: ghcide status: needs repro type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Jan 12, 2021
@hasufell hasufell added status: needs info Not actionable, because there's missing information and removed old_status: needs repro labels Jul 13, 2022
@michaelpj
Copy link
Collaborator Author

I haven't seen this in ages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: ghcide status: needs info Not actionable, because there's missing information type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

No branches or pull requests

5 participants