TypeError: function Call*MethodIfWrapped() is not a function

RESOLVED FIXED in Firefox 47



4 years ago
3 years ago


(Reporter: 446240525, Assigned: evilpie)


(Blocks: 1 bug)


Firefox Tracking Flags

(firefox47 fixed)



(1 attachment, 1 obsolete attachment)



4 years ago
This doesn't look right:

js> (function*(){yield 1})().next.call({})
typein:1:9 TypeError: CallStarGeneratorMethodIfWrapped method called on incompatible Object
js> newGlobal().eval("(function*(){yield 1})")().next.call({})
typein:2:0 TypeError: function CallStarGeneratorMethodIfWrapped() {
typein:2:0     [native code]
typein:2:0 } is not a function


js> Int8Array.prototype.find.call({})
typein:4:0 TypeError: CallTypedArrayMethodIfWrapped method called on incompatible Object
js> newGlobal().Int8Array.prototype.find.call({})
typein:5:0 TypeError: function CallTypedArrayMethodIfWrapped() {
typein:5:0     [native code]
typein:5:0 } is not a function

Comment 1

4 years ago
I know, kind of annoying to fix.
FWIW, I was also aware of this when I added the CallNonGenericSelfHostedMethod infrastructure and even discussed it with Jason:

15:32 <jandem>     jorendorff: ok that works beautifully; the CrossCompartmentWrapper generator test passes now. Just the error message is a bit confusing if you pass an incompatible object: CallLegacyGeneratorMethodIfWrapped method called on incompatible Array
15:33 <jorendorff> sold
15:33 <jorendorff> I literally do not care about that error message



3 years ago
Duplicate of this bug: 1242154
We should care about this error message.  A web developer running into this will have no clue what's going on and how to fix their code...


3 years ago
Assignee: nobody → evilpies

Comment 5

3 years ago
Created attachment 8717565 [details] [diff] [review]

I almost got this working. However for the cross-compartment case we don't get the proper name.

> newGlobal().Uint8Array.prototype.findIndex.call({})
TypeError: TypedArrayFindIndex method called on incompatible Object
> Uint8Array.prototype.findIndex.call({})
TypeError: findIndex method called on incompatible Object

There must be some way to get the proper cloned function that already has the right name. Otherwise we could apply _SetCanonicalName to every function that uses CallXXXMethodIfWrapped.
Comment on attachment 8717565 [details] [diff] [review]

Review of attachment 8717565 [details] [diff] [review]:

Doesn't intrinsic_ActiveFunction do pretty much exactly what you want here? (In that it returns the function whose name is needed.)

If I'm not overlooking something, then just extracting that into a function called by intrinsic_ActiveFunction and ReportIncompatibleSelfHostedMethod would work, no?

Comment 7

3 years ago
Created attachment 8717658 [details] [diff] [review]
Report the right name when calling selfhosted functions on incompatible objects

\o/ ActiveFunction was the right idea, seems to be working now.
Attachment #8717565 - Attachment is obsolete: true
Attachment #8717658 - Flags: review?(till)
Comment on attachment 8717658 [details] [diff] [review]
Report the right name when calling selfhosted functions on incompatible objects

Review of attachment 8717658 [details] [diff] [review]:

Very nice, thank you! r=me with dead code removed.

::: js/src/vm/SelfHosting.cpp
@@ +1396,5 @@
> +    // because they always call the different CallXXXMethodIfWrapped methods,
> +    // which would be reported as the called function instead.
> +
> +    MOZ_ASSERT(args.length() > 0);
> +    RootedPropertyName name(cx, args[args.length() - 1].toString()->asAtom().asPropertyName());

This isn't used anymore.
Attachment #8717658 - Flags: review?(till) → review+

Comment 10

3 years ago
Last Resolved: 3 years ago
status-firefox47: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla47


3 years ago
Blocks: 622261
You need to log in before you can comment on or make changes to this bug.