Note: There are a few cases of duplicates in user autocompletion which are being worked on.

IPDL compiler doesn't generate code to handle message type SHMEM_CREATED_MESSAGE_TYPE when no other async messages are declared

RESOLVED FIXED in mozilla12

Status

()

Core
IPC
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: ajuma, Assigned: ajuma)

Tracking

Trunk
mozilla12
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

6 years ago
When the declaration of a manager protocol doesn't include any async messages received by the parent, the ipdl compiler does not generate code to handle messages of type SHMEM_CREATED_MESSAGE_TYPE in Parent::OnMessageReceived(Message&). A workaround is simply adding an (unused) async message to the protocol declaration.
That is ... most odd.  I don't have a guess for what's up.  Probably an easy fix.
(Assignee)

Comment 2

6 years ago
The problem is related to lines 2885-2890 of ipc/ipdl/ipdl/lower.py:

            if switch.nr_cases > 1:
                method.addstmt(switch)
            else:
                method.addstmt(StmtReturn(_Result.NotKnown))

When a protocol has no async messages declared, at the point at which this snippet gets executed (during the generation of Parent.cpp::OnMessageReceived(Message&)) the only case added to |switch| (which is self.asyncSwitch here) is the default case, so |switch| doesn't get added to the method. Then, lines 3530-3536 (which add the SHMEM_CREATED/DESTROYED handlers to self.asyncSwitch) have no effect on the generated method.

Indeed, changing line 2885 to:

            if switch.nr_cases > 0:

fixes the problem (but breaks bug 509581).
(Assignee)

Comment 3

6 years ago
An example of a protocol where we have to work around this bug is PCompositor.ipdl in Attachment 587713 [details] [diff], Bug 711168.
OK, that makes sense.  The control flow is way too hard to follow in there.

The simplest fix looks like moving

        # FIXME/bug 535053: only manager protocols and non-manager
        # protocols with union types need Lookup().  we'll give it to
        # all for the time being (simpler)
        if 1 or ptype.isManager():
            self.cls.addstmts(self.implementManagerIface())

before 

        def makeHandlerMethod(name, switch, hasReply, dispatches=0):
            params = [ Decl(Type('Message', const=1, ref=1), msgvar.name) ]

The "right" fix is to rewrite this code again :/.
(Assignee)

Updated

6 years ago
Assignee: nobody → ajuma
(Assignee)

Comment 5

6 years ago
Created attachment 588131 [details] [diff] [review]
Make IPDL compiler generate code to handle SHMEM-related messages even when there are no other async messages

This implements the fix from Comment 4.
Attachment #588131 - Flags: review?(jones.chris.g)
Comment on attachment 588131 [details] [diff] [review]
Make IPDL compiler generate code to handle SHMEM-related messages even when there are no other async messages

It would extremely gross to write a test for this, and not all that incredibly useful IMHO, so r=me without that.
Attachment #588131 - Flags: review?(jones.chris.g) → review+
(Assignee)

Comment 7

6 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/f9413ba08c26
Target Milestone: --- → mozilla12
https://hg.mozilla.org/mozilla-central/rev/f9413ba08c26
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.