8000 Duplicate h$listProps · Issue #556 · ghcjs/ghcjs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Duplicate h$listProps #556

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
wuzzeb opened this issue Dec 19, 2016 · 6 comments
Closed

Duplicate h$listProps #556

wuzzeb opened this issue Dec 19, 2016 · 6 comments

Comments

@wuzzeb
Copy link
wuzzeb commented Dec 19, 2016

I recently updated ghcjs (8.0 git branch), and started getting ThreadAborted errors "TypeError: Cannot read property 't' of undefined" inside the runtime, specifically in the function where h$RTS_580 was undefined.

function h$e(h$RTS_579)
{
  h$r1 = h$RTS_579;
  if((typeof h$RTS_579 !== "object"))
  {
    return h$rs();
  };
  var h$RTS_580 = h$RTS_579.f;
  if((h$RTS_580 === h$unbox_e))
  {
    h$r1 = h$RTS_579.d1;
    return h$rs();
  };
  switch (h$RTS_580.t)
  {
    case (2):
    case (1):
    case (3):
      return h$rs();
    case (5):
      h$p3(h$ap_0_0, h$RTS_579, h$return);
      return h$blockOnBlackhole(h$RTS_579);
    default:
      return h$RTS_580;
  };
};

After single-stepping in the chrome debugger, I eventually traced it to the following problem:

Step 1: I am using the FromJSVal instance for Aeson.Value located in GHCJS.Marshal, which calls listProps from JavaScript.Object.Internal.

Step 2: listProps is unsafeCoerce (js_listProps o) and js_listProps is a foreign call to h$listProps

Step 3: h$listProps is defined in https://github.com/ghcjs/ghcjs-base/blob/master/jsbits/utils.js and properly creates a haskell value containing the properties of the object. So far everything is great.

Problem!: The shim code also contains a function h$listProps: https://github.com/ghcjs/shims/blob/master/src/object.js (also in 8.0 branch) This version of h$listProps does not create a haskell value but just a raw javascript list. If this version of h$listProps is used, the raw javascript list will be unsafeCoerce into a haskell list which eventually causes the crash.

Speculation: something in ghcjs changed the order in which code is generated, which exposed this problem. Before, I suspect that the order in which code was emitted caused the h$listProps from ghcjs-base to be used, but some recent change in ghcjs changed the code order and now h$listProps is being used from shims.

In my generated output, there was only a single call to h$listProps which was coming from the FromJSVal instance, so I just deleted the shim version of h$listProps from the generated output and everything started working. But a long-term fix is to rename one of the functions?

@iand675
Copy link
Contributor
iand675 commented Dec 19, 2016 via email

@wuzzeb
Copy link
Author
wuzzeb commented Dec 19, 2016

I don't think that is the correct fix, since it still relies on the order that code is emitted. If ghcjs ever changes the order so that the ghcjs-base version of h$listProps comes later than the shim version of h$listProps, your code will break.

@iand675
Copy link
Contributor
iand675 commented Dec 22, 2016

That seems to be true, yeah. But in any case, it's a current fix at the moment. The greater issue here though is that all maintainers seem to be MIA.

@waern
Copy link
waern commented Jan 6, 2017

Also found the duplicate h$listProps after single-stepping with chrome debugger. I wish I'd found this issue first!

@mbeidler
Copy link

This issue is not exclusive to 8.0. With the lts-6.20 stack resolver this issue is not reproducible for me, but with lts-6.30 it is (both are GHC 7.10.3).

@hamishmack
Copy link
Member

This should have been fixed by ghcjs/shims#41

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

5 participants
0