mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1208226 - Don't crash when failing to map a segment of shared memory. r=sotaro, billm
This commit is contained in:
parent
e8856d4c4e
commit
8bd23218d3
@ -118,6 +118,7 @@ public:
|
||||
static already_AddRefed<gfxShmSharedReadLock>
|
||||
Open(mozilla::layers::ISurfaceAllocator* aAllocator, const mozilla::layers::ShmemSection& aShmemSection)
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(aShmemSection.shmem().IsReadable());
|
||||
RefPtr<gfxShmSharedReadLock> readLock = new gfxShmSharedReadLock(aAllocator, aShmemSection);
|
||||
return readLock.forget();
|
||||
}
|
||||
|
@ -522,6 +522,8 @@ BufferTextureHost::Upload(nsIntRegion *aRegion)
|
||||
// We don't have a buffer; a possible cause is that the IPDL actor
|
||||
// is already dead. This inevitably happens as IPDL actors can die
|
||||
// at any time, so we want to silently return in this case.
|
||||
// another possible cause is that IPDL failed to map the shmem when
|
||||
// deserializing it.
|
||||
return false;
|
||||
}
|
||||
if (!mCompositor) {
|
||||
@ -651,9 +653,19 @@ ShmemTextureHost::ShmemTextureHost(const ipc::Shmem& aShmem,
|
||||
ISurfaceAllocator* aDeallocator,
|
||||
TextureFlags aFlags)
|
||||
: BufferTextureHost(aDesc, aFlags)
|
||||
, mShmem(MakeUnique<ipc::Shmem>(aShmem))
|
||||
, mDeallocator(aDeallocator)
|
||||
{
|
||||
if (aShmem.IsReadable()) {
|
||||
mShmem = MakeUnique<ipc::Shmem>(aShmem);
|
||||
} else {
|
||||
// This can happen if we failed to map the shmem on this process, perhaps
|
||||
// because it was big and we didn't have enough contiguous address space
|
||||
// available, even though we did on the child process.
|
||||
// As a result this texture will be in an invalid state and Lock will
|
||||
// always fail.
|
||||
gfxCriticalError() << "Failed to create a valid ShmemTextureHost";
|
||||
}
|
||||
|
||||
MOZ_COUNT_CTOR(ShmemTextureHost);
|
||||
}
|
||||
|
||||
|
@ -4297,13 +4297,16 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
init=ExprCall(p.lookupSharedMemory(), args=[ idvar ]))
|
||||
])
|
||||
|
||||
failif = StmtIf(ExprNot(rawvar))
|
||||
failif.addifstmt(StmtReturn(_Result.ValuError))
|
||||
# Here we don't return an error if we failed to look the shmem up. This
|
||||
# is because we don't have a way to know if it is because we failed to
|
||||
# map the shmem or if the id is wrong. In the latter case it would be
|
||||
# better to catch the error but the former case is legit...
|
||||
lookupif = StmtIf(rawvar)
|
||||
lookupif.addifstmt(StmtExpr(p.removeShmemId(idvar)))
|
||||
lookupif.addifstmt(StmtExpr(_shmemDealloc(rawvar)))
|
||||
|
||||
case.addstmts([
|
||||
failif,
|
||||
StmtExpr(p.removeShmemId(idvar)),
|
||||
StmtExpr(_shmemDealloc(rawvar)),
|
||||
lookupif,
|
||||
StmtReturn(_Result.Processed)
|
||||
])
|
||||
|
||||
@ -4669,7 +4672,12 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
||||
StmtDecl(Decl(_rawShmemType(ptr=1), rawvar.name),
|
||||
init=_lookupShmem(idvar)),
|
||||
iffound,
|
||||
StmtReturn.FALSE
|
||||
# This is ugly: we failed to look the shmem up, most likely because
|
||||
# we failed to map it the first time it was deserialized. we create
|
||||
# an empty shmem and let the user of the shmem deal with it.
|
||||
# if we returned false here we would crash.
|
||||
StmtExpr(ExprAssn(ExprDeref(var), ExprCall(ExprVar('Shmem'), args=[]) )),
|
||||
StmtReturn.TRUE
|
||||
])
|
||||
|
||||
self.cls.addstmts([ write, Whitespace.NL, read, Whitespace.NL ])
|
||||
|
Loading…
Reference in New Issue
Block a user