From b13339839e5f74715200146bf3c7c626f8d262a8 Mon Sep 17 00:00:00 2001 From: Gabriel Valcazar Date: Wed, 9 Dec 2020 16:36:34 +0100 Subject: [PATCH] cog: fix crash due to EGL library errors The EGL library provided by NXP in the v5.4.47 BSP has a bug where a NULL pointer is returned by eglGetProcAddress() when trying to obtain the entrypoint for a specific function used throughout the cog code. This caused cog to crash immediately after launching it. Recently, a fix was made available in the cog repo, so backport it to the latest available revision of cog in meta-webkit and apply it. https://jira.digi.com/browse/DEL-7311 https://jira.digi.com/browse/DEL-7312 https://jira.digi.com/browse/DEL-7339 Signed-off-by: Gabriel Valcazar --- ...ommon-EGL-proc-address-loader-with-d.patch | 84 +++++++++++++++++++ ...-proc-address.h-add-a-license-header.patch | 23 +++++ .../recipes-browser/cog/cog_0.7.1.bbappend | 8 ++ 3 files changed, 115 insertions(+) create mode 100644 meta-digi-dey/dynamic-layers/webkit/recipes-browser/cog/cog/0001-platform-add-a-common-EGL-proc-address-loader-with-d.patch create mode 100644 meta-digi-dey/dynamic-layers/webkit/recipes-browser/cog/cog/0002-egl-proc-address.h-add-a-license-header.patch create mode 100644 meta-digi-dey/dynamic-layers/webkit/recipes-browser/cog/cog_0.7.1.bbappend diff --git a/meta-digi-dey/dynamic-layers/webkit/recipes-browser/cog/cog/0001-platform-add-a-common-EGL-proc-address-loader-with-d.patch b/meta-digi-dey/dynamic-layers/webkit/recipes-browser/cog/cog/0001-platform-add-a-common-EGL-proc-address-loader-with-d.patch new file mode 100644 index 000000000..ed1d3b057 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/webkit/recipes-browser/cog/cog/0001-platform-add-a-common-EGL-proc-address-loader-with-d.patch @@ -0,0 +1,84 @@ +From: Zan Dobersek +Date: Tue, 10 Nov 2020 09:23:16 +0100 +Subject: [PATCH 1/4] platform: add a common EGL proc address loader with dlsym + fallback + +Provide a common EGL proc address loader function that incorporates +a dlsym-based fallback in case eglGetProcAddress() refuses to find +an otherwise-existing entrypoint. + +This should avoid some drivers that fail to handle proc address +requests for specific entrypoints, but have those entrypoints +exported as regular symbols loadable through dlsym(). +--- + platform/cog-platform-drm.c | 4 +++- + platform/cog-platform-fdo.c | 4 +++- + platform/common/egl-proc-address.h | 15 +++++++++++++++ + 3 files changed, 21 insertions(+), 2 deletions(-) + create mode 100644 platform/common/egl-proc-address.h + +diff --git a/platform/cog-platform-drm.c b/platform/cog-platform-drm.c +index 6fa4a25..27b4521 100644 +--- a/platform/cog-platform-drm.c ++++ b/platform/cog-platform-drm.c +@@ -16,6 +16,8 @@ + #include + #include + ++#include "common/egl-proc-address.h" ++ + + #if !defined(EGL_EXT_platform_base) + typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list); +@@ -379,7 +381,7 @@ init_egl (void) + { + static PFNEGLGETPLATFORMDISPLAYEXTPROC s_eglGetPlatformDisplay = NULL; + if (!s_eglGetPlatformDisplay) +- s_eglGetPlatformDisplay = (PFNEGLGETPLATFORMDISPLAYEXTPROC) eglGetProcAddress ("eglGetPlatformDisplayEXT"); ++ s_eglGetPlatformDisplay = (PFNEGLGETPLATFORMDISPLAYEXTPROC) load_egl_proc_address ("eglGetPlatformDisplayEXT"); + + if (s_eglGetPlatformDisplay) + egl_data.display = s_eglGetPlatformDisplay (EGL_PLATFORM_GBM_KHR, gbm_data.device, NULL); +diff --git a/platform/cog-platform-fdo.c b/platform/cog-platform-fdo.c +index 960bc98..7bdf075 100644 +--- a/platform/cog-platform-fdo.c ++++ b/platform/cog-platform-fdo.c +@@ -32,6 +32,8 @@ + #include + #include + ++#include "common/egl-proc-address.h" ++ + #include "xdg-shell-client.h" + #include "fullscreen-shell-unstable-v1-client.h" + #include "presentation-time-client.h" +@@ -1586,7 +1588,7 @@ on_export_fdo_egl_image(void *data, struct wpe_fdo_egl_exported_image *image) + s_eglCreateWaylandBufferFromImageWL; + if (s_eglCreateWaylandBufferFromImageWL == NULL) { + s_eglCreateWaylandBufferFromImageWL = (PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWL) +- eglGetProcAddress ("eglCreateWaylandBufferFromImageWL"); ++ load_egl_proc_address ("eglCreateWaylandBufferFromImageWL"); + g_assert (s_eglCreateWaylandBufferFromImageWL); + } + +diff --git a/platform/common/egl-proc-address.h b/platform/common/egl-proc-address.h +new file mode 100644 +index 0000000..44dd6a9 +--- /dev/null ++++ b/platform/common/egl-proc-address.h +@@ -0,0 +1,15 @@ ++#pragma once ++ ++#define __USE_GNU ++#include ++ ++#include ++ ++static void* ++load_egl_proc_address (const char *name) ++{ ++ void *proc_address = eglGetProcAddress (name); ++ if (!proc_address) ++ proc_address = dlsym (RTLD_NEXT, name); ++ return proc_address; ++} diff --git a/meta-digi-dey/dynamic-layers/webkit/recipes-browser/cog/cog/0002-egl-proc-address.h-add-a-license-header.patch b/meta-digi-dey/dynamic-layers/webkit/recipes-browser/cog/cog/0002-egl-proc-address.h-add-a-license-header.patch new file mode 100644 index 000000000..bfbfadb4b --- /dev/null +++ b/meta-digi-dey/dynamic-layers/webkit/recipes-browser/cog/cog/0002-egl-proc-address.h-add-a-license-header.patch @@ -0,0 +1,23 @@ +From: Zan Dobersek +Date: Tue, 10 Nov 2020 09:42:01 +0100 +Subject: [PATCH 2/4] egl-proc-address.h: add a license header. + +--- + platform/common/egl-proc-address.h | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/platform/common/egl-proc-address.h b/platform/common/egl-proc-address.h +index 44dd6a9..83ad90a 100644 +--- a/platform/common/egl-proc-address.h ++++ b/platform/common/egl-proc-address.h +@@ -1,3 +1,10 @@ ++/* ++ * egl-proc-address.h ++ * Copyright (C) 2020 Igalia S.L. ++ * ++ * Distributed under terms of the MIT license. ++ */ ++ + #pragma once + + #define __USE_GNU diff --git a/meta-digi-dey/dynamic-layers/webkit/recipes-browser/cog/cog_0.7.1.bbappend b/meta-digi-dey/dynamic-layers/webkit/recipes-browser/cog/cog_0.7.1.bbappend new file mode 100644 index 000000000..32d03d065 --- /dev/null +++ b/meta-digi-dey/dynamic-layers/webkit/recipes-browser/cog/cog_0.7.1.bbappend @@ -0,0 +1,8 @@ +# Copyright 2020, Digi International Inc. + +FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" + +SRC_URI_append = " \ + file://0001-platform-add-a-common-EGL-proc-address-loader-with-d.patch \ + file://0002-egl-proc-address.h-add-a-license-header.patch \ +"