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

cannot coerce detailsToken to string #729

Closed
dckc opened this issue May 14, 2021 · 2 comments · Fixed by #772
Closed

cannot coerce detailsToken to string #729

dckc opened this issue May 14, 2021 · 2 comments · Fixed by #772
Assignees
Labels
bug Something isn't working debugging support

Comments

@dckc
Copy link
Contributor

dckc commented May 14, 2021

We construct detailsToken as follows:

const detailsToken = freeze({ __proto__: null });

and similarly on line 92.

Then in assert.note, we attempt to stringify it:

  if (hiddenDetails === undefined) {
    throw new Error(`unrecognized details ${detailsNote}`);
  }

On XS, this throws cannot coerce object to string. On node, likewise:

> `${{__proto__: null}}`
Thrown:
TypeError: Cannot convert object to primitive value

It seems error-prone to try to prevent stringifying detailsToken, so I suggest adding toString() methods.

context:

The moddable folks pointed this out in the course of debugging Agoric/agoric-sdk#3039; it was triggered in trackTurns:

  if (hiddenPriorError !== undefined) {
    assert.note(sendingError, X`Caused by: ${hiddenPriorError}`);
  }
@erights
Copy link
Contributor

erights commented Jun 8, 2021

@dckc I agree with your recommendation and will do that. But reading the code, I am confused how this arose. The detailsToken constructed near lines 72 and 92 are both followed by

hiddenDetailsMap.set(detailsToken, { template, args });

We never remove it from that weakmap or store anything else in there. The line immediate prior to both occurrences of the test you show above is

  const hiddenDetails = hiddenDetailsMap.get(optDetails);

Thus, for the detailsTokens made near lines 72 and 92, if we are using the same instance of the assert module and thus the same weakmap, I don't see how hiddenDetails can ever be undefined.

If we are instantiating the assert module twice, so that one doesn't recognize the detailsToken generated by the other, that itself would be a bad problem we need to fix. Can you help me reproduce this?

@dckc
Copy link
Contributor Author

dckc commented Jun 8, 2021

@dckc ... We never remove it from that weakmap ... I don't see how hiddenDetails can ever be undefined. ... Can you help me reproduce this?

I'm not confident that I can, on node; as I say, this arose in the context of Agoric/agoric-sdk#3039 , which has since been diagnosed as a GC bug in XS that resulted in things getting dropped from WeakMaps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working debugging support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants