OSDN Git Service

HACK - Avoid crashes on SurfaceFlinger when using software rendering nougat-x86 android-x86-7.1-r1 android-x86-7.1-r2 android-x86-7.1-r3 android-x86-7.1-r4 android-x86-7.1-r5
authorPaulo Sergio Travaglia <pstglia@gmail.com>
Sun, 30 Oct 2016 23:37:16 +0000 (21:37 -0200)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Thu, 4 May 2017 17:10:08 +0000 (01:10 +0800)
When using sw rendering, depending user action (pressing HOME button after
lauching an app, for instance) there's an attempt do map a vaddr that has
already been mapped. And this is done by the process that created it.
This triggers a kernel trap and surfaceflinger is destroyed:

=========================================================================
10-30 18:14:11.474  1096  1645 D gralloc : gralloc_map() succeeded fd=59,
 off=0, size=1028096, vaddr=0xaac21000

10-30 18:14:11.474  1355  1389 D gralloc : gralloc_map() succeeded fd=202,
 off=0, size=1028096, vaddr=0x8d0f2000

10-30 18:14:11.475  1096  1096 D gralloc : Registering a buffer in the
process that created it. This may cause memory ordering problems.

10-30 18:14:11.475  1096  1096 D gralloc : gralloc_map() succeeded
fd=60, off=0, size=1028096, vaddr=0xaac21000

10-30 18:14:11.574  1095  1095 I ServiceManager: service 'gpu' died
=========================================================================

In order to avoid this, the patch avoids mapping a buffer when the
mapping process is the creator process.

This should be threated as a workaround and removed when the real
root cause is discovered.

modules/gralloc/mapper.cpp

index 20d9841..2d637c5 100644 (file)
@@ -116,9 +116,11 @@ int gralloc_register_buffer(gralloc_module_t const* module,
     //   problems. Most modern L1 caches fit that description.
 
     private_handle_t* hnd = (private_handle_t*)handle;
-    ALOGD_IF(hnd->pid == getpid(),
-            "Registering a buffer in the process that created it. "
-            "This may cause memory ordering problems.");
+    if (hnd->pid == getpid()) {
+        ALOGD("Avoid registering a buffer in the process that created it. "
+              "This may cause memory ordering problems.");
+        return 1;
+    }
 
     void *vaddr;
     return gralloc_map(module, handle, &vaddr);