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

RESOLVED FIXED in Firefox 47

Status

()

Core
JavaScript Engine
RESOLVED FIXED
3 years ago
2 years ago

People

(Reporter: ziyunfei, Assigned: evilpie)

Tracking

(Blocks: 1 bug)

Trunk
mozilla47
Points:
---

Firefox Tracking Flags

(firefox47 fixed)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

3 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

and

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
(Assignee)

Comment 1

3 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

http://logs.glob.uno/?c=mozilla%23jsapi&s=14+Oct+2014&e=14+Oct+2014#c490686
(Assignee)

Updated

2 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...
(Assignee)

Updated

2 years ago
Assignee: nobody → evilpies
(Assignee)

Comment 5

2 years ago
Created attachment 8717565 [details] [diff] [review]
WIP

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]
WIP

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?
(Assignee)

Comment 7

2 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

2 years ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/9d9527de1caa
Status: NEW → RESOLVED
Last Resolved: 2 years ago
status-firefox47: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
(Assignee)

Updated

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