Bug 968244 - Make IPDL-generated code not crash on bad shmems - r=bent

This commit is contained in:
Benoit Jacob 2014-02-25 08:57:10 -05:00
parent a6f546f393
commit c2a3a79571

View File

@ -4035,8 +4035,10 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
# bool AdoptShmem(const Shmem& mem, Shmem* outmem):
# SharedMemory* raw = mem.mSegment;
# if (!raw || IsTrackingSharedMemory(raw))
# RUNTIMEABORT()
# if (!raw || IsTrackingSharedMemory(raw)) {
# NS_WARNING("bad Shmem"); // or NS_RUNTIMEABORT on child side
# return false;
# }
# id_t id
# if (!AdoptSharedMemory(raw, &id))
# return false
@ -4053,7 +4055,14 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
ifbad = StmtIf(ExprBinary(
ExprNot(rawvar), '||',
ExprCall(ExprVar('IsTrackingSharedMemory'), args=[ rawvar ])))
ifbad.addifstmt(_runtimeAbort('bad Shmem'))
badShmemActions = []
if (self.side == 'child'):
badShmemActions.append(_runtimeAbort('bad Shmem'));
else:
badShmemActions.append(_printWarningMessage('bad Shmem'));
badShmemActions.append(StmtReturn.FALSE);
ifbad.addifstmts(badShmemActions)
adoptShmem.addstmt(ifbad)
ifadoptfails = StmtIf(ExprNot(ExprCall(
@ -4074,7 +4083,8 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
# bool ok = DestroySharedMemory(mem);
##ifdef DEBUG
# if (!ok) {
# NS_RUNTIMEABORT("bad Shmem");
# NS_WARNING("bad Shmem"); // or NS_RUNTIMEABORT on child side
# return false;
# }
##endif // DEBUG
# mem.forget();
@ -4086,7 +4096,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
okvar = ExprVar('ok')
ifbad = StmtIf(ExprNot(okvar))
ifbad.addifstmt(_runtimeAbort('bad Shmem'))
ifbad.addifstmts(badShmemActions)
deallocShmem.addstmts([
StmtDecl(Decl(Type.BOOL, okvar.name),