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

Mapping over PairRDD using Tuple2 results in GHC bug - makeStatic #119

Closed
dzhus opened this issue Dec 12, 2017 · 3 comments · Fixed by #121
Closed

Mapping over PairRDD using Tuple2 results in GHC bug - makeStatic #119

dzhus opened this issue Dec 12, 2017 · 3 comments · Fixed by #121

Comments

@dzhus
Copy link
Collaborator

dzhus commented Dec 12, 2017

When trying to map a function that swaps Tuple2 members over a PairRDD a b to get PairRDD b a, I'm seeing this:

$ stack --nix build && stack --nix exec -- sparkle package sparkle-example-rddops && stack --nix exec -- spark-submit --master 'local[1]' sparkle-example-rddops.jar

...

["The","quick","brown","fox","jumps","over","the","lazy","dog"]
"dog lazy the over jumps fox brown quick The"
["ehT","kciuq","nworb","xof","spmuj","revo","eht","yzal","god"]
["The","quick","brown"]
["fox","The","jumps","quick","lazy","dog","over","brown","the"]
True
sparkle-worker: GHC bug - makeStatic: Unresolved static form at line 107, column 1.
CallStack (from HasCallStack):
  error, called at libraries/base/GHC/StaticPtr/Internal.hs:26:5 in base:GHC.StaticPtr.Internal
$ uname -a
Linux osboxes 4.8.0-36-generic #36~16.04.1-Ubuntu SMP Sun Feb 5 09:39:57 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Here's a minimal example: MailOnline@4191d4f

If I add StaticPointers pragma to PairRDD module, it works as expected (MailOnline@6708a2a). Any ideas as to what is exactly happening here? Is this a combination of https://ghc.haskell.org/trac/ghc/ticket/14204 + withStatic in PairRDD?

@mboes
Copy link
Member

mboes commented Dec 12, 2017

Yes, that's right. I got hit myself by this earlier last week. If you'd like to push your change as a PR, I can cut a new point release pronto. Thanks for the bug report!

FWIW, GHC 8.4 should have much better diagnostics.

@mboes
Copy link
Member

mboes commented Dec 12, 2017

I should clarify - in my case it was a missing LANGUAGE pragma in Language.Java (now fixed). It's unclear why this is showing up now though, seeing as these LANGUAGE pragmas must have been missing for a long time. Might be due to a new compiler version. There might be a few more of these lurking around, since the GHC bug you mention turns what ought to be a compile time error into a runtime error.

dzhus added a commit to MailOnline/sparkle-ARCHIVED that referenced this issue Dec 12, 2017
Fixes tweag#119

This is caused by https://ghc.haskell.org/trac/ghc/ticket/14204 +
withStatic TH macro used to create instances in PairRDD module. The
bug results in `static` being allowed to be used with Tuple2
constructor without a compile-time error, which instead leads to a
run-time one. For example,

    swapPair :: Tuple2 a b -> Tuple2 b a
    swapPair (Tuple2 a b) = Tuple2 b a

    mapSwap :: ( Static (Reify a), Static (Reify b)
               , Static (Reflect a), Static (Reflect b)
               , Typeable a, Typeable b)
            => PairRDD a b
            -> IO (PairRDD b a)
    mapSwap rdd =
      PairRDD.fromRDD =<<
      RDD.map (closure (static swapPair)) =<<
      PairRDD.toRDD rdd

fails with

    sparkle-worker: GHC bug - makeStatic: Unresolved static form at line 107, column 1.
    CallStack (from HasCallStack):
      error, called at libraries/base/GHC/StaticPtr/Internal.hs:26:5 in base:GHC.StaticPtr.Internal
@dzhus
Copy link
Collaborator Author

dzhus commented Dec 12, 2017

Thanks, I opened a PR. There's no rush to make a new release – I'm fine using Git version, plus I have more changes coming.

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

Successfully merging a pull request may close this issue.

2 participants