From dd21530757e6af04eb8c62c5e5dd415444cc99e1 Mon Sep 17 00:00:00 2001 From: Nika Layzell Date: Fri, 26 Aug 2022 16:08:06 +0000 Subject: [PATCH] Bug 1781129 - Part 4: Fix issues caused by Shmem arguments no longer being visible to ipdl, r=ipc-reviewers,jld Due to Shmem implementing ParamTraits, it is possible for a Shmem argument to not be visible to the IPDL compiler as it is only serialized within an opaque type included with `using`. If that happens, it would cause the construction of the Shmem to fail on the other side, in a hard to diagnose manner. This changes the logic to always allow any actor to manage shmems, to make it more in line with the `AllocShmem` method being directly declared on IProtocol. This specifically caused issues after this patch stack with PContent, which no longer has any shmem arguments visible to IPDL after these changes, but still is used as a manager for Shmems included in some messages. Differential Revision: https://phabricator.services.mozilla.com/D151855 --- ipc/ipdl/ipdl/lower.py | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/ipc/ipdl/ipdl/lower.py b/ipc/ipdl/ipdl/lower.py index 6615467b2539..e61336558ca6 100644 --- a/ipc/ipdl/ipdl/lower.py +++ b/ipc/ipdl/ipdl/lower.py @@ -4321,30 +4321,18 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): methods = [] if p.decl.type.isToplevel(): - - # "private" message that passes shmem mappings from one process - # to the other - if p.subtreeUsesShmem(): - self.asyncSwitch.addcase( - CaseLabel("SHMEM_CREATED_MESSAGE_TYPE"), - self.genShmemCreatedHandler(), - ) - self.asyncSwitch.addcase( - CaseLabel("SHMEM_DESTROYED_MESSAGE_TYPE"), - self.genShmemDestroyedHandler(), - ) - else: - abort = StmtBlock() - abort.addstmts( - [ - _fatalError("this protocol tree does not use shmem"), - StmtReturn(_Result.NotKnown), - ] - ) - self.asyncSwitch.addcase(CaseLabel("SHMEM_CREATED_MESSAGE_TYPE"), abort) - self.asyncSwitch.addcase( - CaseLabel("SHMEM_DESTROYED_MESSAGE_TYPE"), abort - ) + # FIXME: This used to be declared conditionally based on whether + # shmem appeared somewhere in the protocol hierarchy, however that + # caused issues due to Shmem instances hidden within custom C++ + # types. + self.asyncSwitch.addcase( + CaseLabel("SHMEM_CREATED_MESSAGE_TYPE"), + self.genShmemCreatedHandler(), + ) + self.asyncSwitch.addcase( + CaseLabel("SHMEM_DESTROYED_MESSAGE_TYPE"), + self.genShmemDestroyedHandler(), + ) # Keep track of types created with an INOUT ctor. We need to call # Register() or RegisterID() for them depending on the side the managee