Accepting request 1036008 from home:plater
- Removed reverse-0001-fix-memory-leaks-on-testbed.patch and added 0001-fix-memory-corruption-when-unregistering-plugins.patch as final fix for https://github.com/hughsie/colord/issues/145 OBS-URL: https://build.opensuse.org/request/show/1036008 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/lcms2?expand=0&rev=83
This commit is contained in:
parent
583dabbf14
commit
1bb71be9b3
77
0001-fix-memory-corruption-when-unregistering-plugins.patch
Normal file
77
0001-fix-memory-corruption-when-unregistering-plugins.patch
Normal file
@ -0,0 +1,77 @@
|
||||
From a9e4601ceb3a185d4f78cc0cfbd285cf0c399e9d Mon Sep 17 00:00:00 2001
|
||||
From: Marti Maria <marti.maria@littlecms.com>
|
||||
Date: Sat, 12 Nov 2022 20:00:46 +0100
|
||||
Subject: [PATCH] fix memory corruption when unregistering plugins
|
||||
|
||||
unregistering plugins twice may corrupt memory. This commit fixes that.
|
||||
---
|
||||
plugins/fast_float/testbed/fast_float_testbed.c | 4 ++--
|
||||
src/cmsplugin.c | 16 +++++++++-------
|
||||
2 files changed, 11 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/plugins/fast_float/testbed/fast_float_testbed.c b/plugins/fast_float/testbed/fast_float_testbed.c
|
||||
index ea23c10..addef00 100644
|
||||
--- a/plugins/fast_float/testbed/fast_float_testbed.c
|
||||
+++ b/plugins/fast_float/testbed/fast_float_testbed.c
|
||||
@@ -2468,7 +2468,7 @@ int main()
|
||||
trace("Installing plug-in ... ");
|
||||
cmsPlugin(cmsFastFloatExtensions());
|
||||
trace("done.\n\n");
|
||||
-
|
||||
+
|
||||
CheckComputeIncrements();
|
||||
|
||||
// 15 bit functionality
|
||||
@@ -2508,7 +2508,7 @@ int main()
|
||||
|
||||
trace("\nAll tests passed OK\n");
|
||||
|
||||
- cmsUnregisterPlugins();
|
||||
+ cmsDeleteContext(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
diff --git a/src/cmsplugin.c b/src/cmsplugin.c
|
||||
index 7d038d2..1d8c358 100644
|
||||
--- a/src/cmsplugin.c
|
||||
+++ b/src/cmsplugin.c
|
||||
@@ -795,9 +795,7 @@ void* _cmsContextGetClientChunk(cmsContext ContextID, _cmsMemoryClient mc)
|
||||
// many different plug-ins simultaneously, then there is no way to
|
||||
// identify which plug-in to unregister.
|
||||
void CMSEXPORT cmsUnregisterPluginsTHR(cmsContext ContextID)
|
||||
-{
|
||||
- struct _cmsContext_struct* ctx = _cmsGetContext(ContextID);
|
||||
-
|
||||
+{
|
||||
_cmsRegisterMemHandlerPlugin(ContextID, NULL);
|
||||
_cmsRegisterInterpPlugin(ContextID, NULL);
|
||||
_cmsRegisterTagTypePlugin(ContextID, NULL);
|
||||
@@ -811,9 +809,6 @@ void CMSEXPORT cmsUnregisterPluginsTHR(cmsContext ContextID)
|
||||
_cmsRegisterMutexPlugin(ContextID, NULL);
|
||||
_cmsRegisterParallelizationPlugin(ContextID, NULL);
|
||||
|
||||
- if (ctx->MemPool != NULL)
|
||||
- _cmsSubAllocDestroy(ctx->MemPool);
|
||||
- ctx->MemPool = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -981,7 +976,14 @@ cmsContext CMSEXPORT cmsDupContext(cmsContext ContextID, void* NewUserData)
|
||||
// The ContextID can no longer be used in any THR operation.
|
||||
void CMSEXPORT cmsDeleteContext(cmsContext ContextID)
|
||||
{
|
||||
- if (ContextID != NULL) {
|
||||
+ if (ContextID == NULL) {
|
||||
+
|
||||
+ cmsUnregisterPlugins();
|
||||
+ if (globalContext.MemPool != NULL)
|
||||
+ _cmsSubAllocDestroy(globalContext.MemPool);
|
||||
+ globalContext.MemPool = NULL;
|
||||
+ }
|
||||
+ else {
|
||||
|
||||
struct _cmsContext_struct* ctx = (struct _cmsContext_struct*) ContextID;
|
||||
struct _cmsContext_struct fakeContext;
|
||||
--
|
||||
2.35.3
|
||||
|
@ -1,3 +1,10 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Nov 16 07:39:44 UTC 2022 - Dave Plater <davejplater@gmail.com>
|
||||
|
||||
- Removed reverse-0001-fix-memory-leaks-on-testbed.patch and added
|
||||
0001-fix-memory-corruption-when-unregistering-plugins.patch as
|
||||
final fix for https://github.com/hughsie/colord/issues/145
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Nov 11 13:40:18 UTC 2022 - Dave Plater <davejplater@gmail.com>
|
||||
|
||||
|
@ -27,9 +27,7 @@ Source0: https://github.com/mm2/Little-CMS/releases/download/lcms%{versio
|
||||
Source1: baselibs.conf
|
||||
Patch0: lcms2-ocloexec.patch
|
||||
Patch1: lcms2-visibility.patch
|
||||
%ifarch i586
|
||||
Patch2: reverse-0001-fix-memory-leaks-on-testbed.patch
|
||||
%endif
|
||||
Patch2: 0001-fix-memory-corruption-when-unregistering-plugins.patch
|
||||
%if 0%{?suse_version}
|
||||
BuildRequires: autoconf
|
||||
BuildRequires: glibc-devel
|
||||
|
@ -1,204 +0,0 @@
|
||||
Index: b/plugins/fast_float/testbed/fast_float_testbed.c
|
||||
===================================================================
|
||||
--- a/plugins/fast_float/testbed/fast_float_testbed.c 2022-11-01 12:13:11.000000000 +0200
|
||||
+++ b/plugins/fast_float/testbed/fast_float_testbed.c 2022-11-11 14:18:08.695497815 +0200
|
||||
@@ -24,10 +24,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
|
||||
-// On Visual Studio, use debug CRT
|
||||
-#ifdef _MSC_VER
|
||||
-# include "crtdbg.h"
|
||||
-#endif
|
||||
|
||||
#define PROFILES_DIR "../../test_profiles/"
|
||||
|
||||
@@ -58,12 +54,12 @@ typedef struct { cmsFloat32Number L, a,
|
||||
static
|
||||
void trace(const char* frm, ...)
|
||||
{
|
||||
- va_list args;
|
||||
+ va_list args;
|
||||
|
||||
- va_start(args, frm);
|
||||
- vfprintf(stderr, frm, args);
|
||||
- fflush(stderr);
|
||||
- va_end(args);
|
||||
+ va_start(args, frm);
|
||||
+ vfprintf(stderr, frm, args);
|
||||
+ fflush(stderr);
|
||||
+ va_end(args);
|
||||
}
|
||||
|
||||
|
||||
@@ -592,9 +588,9 @@ void CheckUncommonValues(cmsHPROFILE hlc
|
||||
|
||||
for (i = 0; i < npixels; i++)
|
||||
{
|
||||
- bufferIn[i].r = i / 40.0f - 0.5f;
|
||||
- bufferIn[i].g = i / 20.0f - 0.5f;
|
||||
- bufferIn[i].b = i / 60.0f - 0.5f;
|
||||
+ bufferIn[i].r = i / 40.0 - 0.5;
|
||||
+ bufferIn[i].g = i / 20.0 - 0.5;
|
||||
+ bufferIn[i].b = i / 60.0 - 0.5;
|
||||
}
|
||||
|
||||
cmsDoTransform(xformPlugin, bufferIn, bufferPluginOut, npixels);
|
||||
@@ -677,7 +673,7 @@ void CheckToEncodedLab(void)
|
||||
}
|
||||
|
||||
|
||||
- cmsDeleteTransform(xform); cmsDeleteTransform(xform_plugin);
|
||||
+ cmsDeleteTransform(xform);
|
||||
cmsCloseProfile(hsRGB); cmsCloseProfile(hLab);
|
||||
cmsDeleteContext(Raw);
|
||||
cmsDeleteContext(Plugin);
|
||||
@@ -720,7 +716,7 @@ void CheckToFloatLab(void)
|
||||
}
|
||||
|
||||
|
||||
- cmsDeleteTransform(xform); cmsDeleteTransform(xform_plugin);
|
||||
+ cmsDeleteTransform(xform);
|
||||
cmsCloseProfile(hsRGB); cmsCloseProfile(hLab);
|
||||
cmsDeleteContext(Raw);
|
||||
cmsDeleteContext(Plugin);
|
||||
@@ -1219,9 +1215,6 @@ void CheckLab2RGB(void)
|
||||
cmsFloat32Number maxInside = 0, maxOutside = 0, L, a, b;
|
||||
|
||||
trace("Checking Lab -> RGB...");
|
||||
- cmsCloseProfile(hLab);
|
||||
- cmsCloseProfile(hRGB);
|
||||
-
|
||||
for (L = 4; L <= 100; L++)
|
||||
{
|
||||
for (a = -30; a < +30; a++)
|
||||
@@ -1327,7 +1320,6 @@ void CheckSoftProofing(void)
|
||||
j++;
|
||||
}
|
||||
|
||||
- free(In); free(Out1); free(Out2);
|
||||
cmsDeleteTransform(hXformNoPlugin);
|
||||
cmsDeleteTransform(hXformPlugin);
|
||||
|
||||
@@ -2180,7 +2172,7 @@ cmsFloat64Number SpeedTestFloatByUsing16
|
||||
}
|
||||
|
||||
diff = clock() - atime;
|
||||
- free(In); free(tmp16);
|
||||
+ free(In);
|
||||
|
||||
cmsDeleteTransform(xform16);
|
||||
return MPixSec(diff);
|
||||
@@ -2450,15 +2442,11 @@ void TestGrayTransformPerformance1()
|
||||
trace("Gray conversion using two devicelinks\t %-12.2f MPixels/Sec.\n", MPixSec(diff));
|
||||
}
|
||||
|
||||
+
|
||||
// The harness test
|
||||
int main()
|
||||
{
|
||||
-
|
||||
-#ifdef _MSC_VER
|
||||
- _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
||||
-#endif
|
||||
-
|
||||
- trace("FastFloating point extensions testbed - 1.6\n");
|
||||
+ trace("FastFloating point extensions testbed - 1.5\n");
|
||||
trace("Copyright (c) 1998-2022 Marti Maria Saguer, all rights reserved\n");
|
||||
|
||||
trace("\nInstalling error logger ... ");
|
||||
@@ -2468,7 +2456,7 @@ int main()
|
||||
trace("Installing plug-in ... ");
|
||||
cmsPlugin(cmsFastFloatExtensions());
|
||||
trace("done.\n\n");
|
||||
-
|
||||
+
|
||||
CheckComputeIncrements();
|
||||
|
||||
// 15 bit functionality
|
||||
@@ -2476,26 +2464,26 @@ int main()
|
||||
Check15bitsConversions();
|
||||
|
||||
// 16 bits functionality
|
||||
- CheckAccuracy16Bits();
|
||||
+ CheckAccuracy16Bits();
|
||||
|
||||
// Lab to whatever
|
||||
CheckLab2RGB();
|
||||
|
||||
// Change format
|
||||
CheckChangeFormat();
|
||||
-
|
||||
+
|
||||
// Soft proofing
|
||||
CheckSoftProofing();
|
||||
-
|
||||
+
|
||||
// Floating point functionality
|
||||
CheckConversionFloat();
|
||||
trace("All floating point tests passed OK\n");
|
||||
-
|
||||
+
|
||||
SpeedTest8();
|
||||
SpeedTest16();
|
||||
SpeedTest15();
|
||||
SpeedTestFloat();
|
||||
-
|
||||
+
|
||||
ComparativeFloatVs16bits();
|
||||
ComparativeLineStride8bits();
|
||||
|
||||
@@ -2508,7 +2496,6 @@ int main()
|
||||
|
||||
trace("\nAll tests passed OK\n");
|
||||
|
||||
- cmsUnregisterPlugins();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Index: b/src/cmsplugin.c
|
||||
===================================================================
|
||||
--- a/src/cmsplugin.c 2022-11-01 12:13:11.000000000 +0200
|
||||
+++ b/src/cmsplugin.c 2022-11-11 14:18:08.699497675 +0200
|
||||
@@ -796,8 +796,6 @@ void* _cmsContextGetClientChunk(cmsConte
|
||||
// identify which plug-in to unregister.
|
||||
void CMSEXPORT cmsUnregisterPluginsTHR(cmsContext ContextID)
|
||||
{
|
||||
- struct _cmsContext_struct* ctx = _cmsGetContext(ContextID);
|
||||
-
|
||||
_cmsRegisterMemHandlerPlugin(ContextID, NULL);
|
||||
_cmsRegisterInterpPlugin(ContextID, NULL);
|
||||
_cmsRegisterTagTypePlugin(ContextID, NULL);
|
||||
@@ -810,10 +808,6 @@ void CMSEXPORT cmsUnregisterPluginsTHR(c
|
||||
_cmsRegisterTransformPlugin(ContextID, NULL);
|
||||
_cmsRegisterMutexPlugin(ContextID, NULL);
|
||||
_cmsRegisterParallelizationPlugin(ContextID, NULL);
|
||||
-
|
||||
- if (ctx->MemPool != NULL)
|
||||
- _cmsSubAllocDestroy(ctx->MemPool);
|
||||
- ctx->MemPool = NULL;
|
||||
}
|
||||
|
||||
|
||||
Index: b/testbed/testcms2.c
|
||||
===================================================================
|
||||
--- a/testbed/testcms2.c 2022-11-01 12:13:11.000000000 +0200
|
||||
+++ b/testbed/testcms2.c 2022-11-11 14:18:08.699497675 +0200
|
||||
@@ -9232,12 +9232,13 @@ int main(int argc, char* argv[])
|
||||
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
|
||||
#endif
|
||||
|
||||
+
|
||||
// First of all, check for the right header
|
||||
- if (cmsGetEncodedCMMversion() != LCMS_VERSION) {
|
||||
- Die("Oops, you are mixing header and shared lib!\nHeader version reports to be '%d' and shared lib '%d'\n", LCMS_VERSION, cmsGetEncodedCMMversion());
|
||||
- }
|
||||
+ if (cmsGetEncodedCMMversion() != LCMS_VERSION) {
|
||||
+ Die("Oops, you are mixing header and shared lib!\nHeader version reports to be '%d' and shared lib '%d'\n", LCMS_VERSION, cmsGetEncodedCMMversion());
|
||||
+ }
|
||||
|
||||
- printf("LittleCMS %2.2f test bed %s %s\n\n", cmsGetEncodedCMMversion() / 1000.0, __DATE__, __TIME__);
|
||||
+ printf("LittleCMS %2.2f test bed %s %s\n\n", LCMS_VERSION / 1000.0, __DATE__, __TIME__);
|
||||
|
||||
if ((argc == 2) && strcmp(argv[1], "--exhaustive") == 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user