From 7fe3508329d71ae6bf539b3a7171f024fc96f517 Mon Sep 17 00:00:00 2001 From: liwentao_uiw Date: Tue, 28 Feb 2023 16:54:09 +0800 Subject: [PATCH] Fix the problem that fork_handler call null func address Developer should gurantee not dlclose lib which regist callback func by pthread_atfork Signed-off-by: liwentao_uiw Change-Id: Id7d27677b1f59f86636eb1aad19cf5a261acd655 --- src/opencl_wrapper.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/opencl_wrapper.cpp b/src/opencl_wrapper.cpp index 756a70b..fbaa52d 100644 --- a/src/opencl_wrapper.cpp +++ b/src/opencl_wrapper.cpp @@ -38,6 +38,8 @@ static const std::vector g_opencl_library_paths = { static std::mutex g_initMutex; bool isInit = false; void *handle_{nullptr}; +// ohos musl pthread_atfork func regist is not compatible with dlclose lib. such as libGLES_mali.so in openCL +static const std::string atfork_lib = "/system/lib64/libGLES_mali.so"; bool InitOpenCL() { std::lock_guard lock(g_initMutex); @@ -72,7 +74,9 @@ bool LoadLibraryFromPath(const std::string &library_path, void **handle_ptr) { #define LOAD_OPENCL_FUNCTION_PTR(func_name) \ func_name = reinterpret_cast(dlsym(*handle_ptr, #func_name)); \ if (func_name == nullptr) { \ - UnLoadOpenCLLibrary(*handle_ptr); \ + if (library_path.compare(atfork_lib) != 0) { \ + UnLoadOpenCLLibrary(*handle_ptr); \ + } \ return false; \ } -- Gitee