Commit e41e86d0 by Peter Collingbourne Committed by Nicolas Capens

Don't unlock Android buffers immediately after locking them.

In some Android gralloc implementations (e.g. minigbm), the lock operation corresponds to mmap, and unlock corresponds to munmap. This means that this code was previously returning an unusable buffer in the case where lockInternal is called passing LOCK_UNLOCKED (e.g. the mipmap buffer initializer in Sampler.cpp), resulting in segfaults later on. To prevent this from happening, don't unlock the native buffer and just leak the reference. Bug: b/142352330 Change-Id: I553801f32978c1d0af4597baad374381585e78ad Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/44168Reviewed-by: 's avatarLingfeng Yang <lfy@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Presubmit-Ready: Peter Collingbourne <pcc@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 91525d85
...@@ -303,13 +303,6 @@ private: ...@@ -303,13 +303,6 @@ private:
// Lock the ANativeWindowBuffer and use its address. // Lock the ANativeWindowBuffer and use its address.
data = lockNativeBuffer(GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN); data = lockNativeBuffer(GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN);
if(lock == sw::LOCK_UNLOCKED)
{
// We're never going to get a corresponding unlock, so unlock
// immediately. This keeps the gralloc reference counts sane.
unlockNativeBuffer();
}
} }
return data; return data;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment