identify coredumps since 7.0.8-21

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
freakout
Posts: 6
Joined: 2013-01-04T04:31:07-07:00
Authentication code: 6789

identify coredumps since 7.0.8-21

Post by freakout »

when compiled on old system (RH6 - glibc 2.1) - yes it's old - Imagemagick cores on "identify t.jpg" - convert works identify cores on every jpeg-image the same way. Imagemagick worked since 7.0.8-20 on this platform. It is not that important for me but i think it may be a hint for a sleeping problem in the code. gdb says:

Code: Select all

(gdb) bt
#0  0xb6adc221 in kill () at finddomain.c:145
#1  0xb6bec1f9 in pthread_kill (thread=19638, signo=-1229103904) at signals.c:69
#2  0xb6bec58b in __pthread_raise (sig=6) at signals.c:200
#3  0xb6adc00b in raise (sig=-1228981252) at ../linuxthreads/sysdeps/unix/sysv/linux/raise.c:34
#4  0xb6add1cb in abort () at ../sysdeps/generic/abort.c:88
#5  0xb73537e6 in MagickSignalHandler () from /opt/imagic/lib/libMagickCore-7.Q16HDRI.so.6
#6  <signal handler called>
Couldn't recognize signal trampoline.
The affecting patch is in cache.c - if i omit this patch from 20->21 diffs Imagemagick works just fine on RH6/glibc-2.1:

Code: Select all

--- ImageMagick-7.0.8-20/MagickCore/cache.c     2018-12-24 00:35:15.000000000 +0100
+++ ImageMagick-7.0.8-21/MagickCore/cache.c     2018-12-27 15:17:26.000000000 +0100
@@ -190,7 +190,9 @@
   char
     *value;

-  cache_info=(CacheInfo *) AcquireCriticalMemory(sizeof(*cache_info));
+  cache_info=(CacheInfo *) AcquireAlignedMemory(1,sizeof(*cache_info));
+  if (cache_info == (CacheInfo *) NULL)
+    ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
   (void) memset(cache_info,0,sizeof(*cache_info));
   cache_info->type=UndefinedCache;
   cache_info->mode=IOMode;
@@ -683,8 +685,7 @@
       */
       if (((cache_info->type == MemoryCache) ||
            (cache_info->type == MapCache)) &&
-          ((clone_info->type == MemoryCache) ||
-           (clone_info->type == MapCache)))
+          ((clone_info->type == MemoryCache) || (clone_info->type == MapCache)))
         {
           (void) memcpy(clone_info->pixels,cache_info->pixels,
             cache_info->number_channels*cache_info->columns*cache_info->rows*
@@ -1068,7 +1069,7 @@
   if (cache_info->semaphore != (SemaphoreInfo *) NULL)
     RelinquishSemaphoreInfo(&cache_info->semaphore);
   cache_info->signature=(~MagickCoreSignature);
-  cache_info=(CacheInfo *) RelinquishMagickMemory(cache_info);
+  cache_info=(CacheInfo *) RelinquishAlignedMemory(cache_info);
   cache=(Cache) NULL;
   return(cache);
 }
@@ -3065,8 +3066,8 @@
           }
           if (p == (const Quantum *) NULL)
             break;
-          (void) memcpy(q,p,(size_t) length*cache_info->number_channels*
-            sizeof(*p));
+          (void) memcpy(q,p,(size_t) (cache_info->number_channels*length*
+            sizeof(*p)));
           q+=cache_info->number_channels;
           if ((s != (void *) NULL) && (r != (const void *) NULL))
             {
@@ -3083,7 +3084,8 @@
       if (p == (const Quantum *) NULL)
         break;
       r=GetVirtualMetacontentFromNexus(cache_info,*virtual_nexus);
-      (void) memcpy(q,p,(size_t) length*cache_info->number_channels*sizeof(*p));
+      (void) memcpy(q,p,(size_t) (cache_info->number_channels*length*
+        sizeof(*p)));
       q+=cache_info->number_channels*length;
       if ((r != (void *) NULL) && (s != (const void *) NULL))
         {
@@ -4961,24 +4963,25 @@
 */

 static inline MagickBooleanType AcquireCacheNexusPixels(
-  const CacheInfo *magick_restrict cache_info,NexusInfo *nexus_info,
-  ExceptionInfo *exception)
+  const CacheInfo *magick_restrict cache_info,const MagickSizeType length,
+  NexusInfo *nexus_info,ExceptionInfo *exception)
 {
-  if (nexus_info->length != (MagickSizeType) ((size_t) nexus_info->length))
+  if (length != (MagickSizeType) ((size_t) length))
     return(MagickFalse);
+  nexus_info->length=0;
+  nexus_info->mapped=MagickFalse;
   if (cache_anonymous_memory <= 0)
     {
-      nexus_info->mapped=MagickFalse;
       nexus_info->cache=(Quantum *) MagickAssumeAligned(AcquireAlignedMemory(1,
-        (size_t) nexus_info->length));
+        (size_t) length));
       if (nexus_info->cache != (Quantum *) NULL)
-        (void) memset(nexus_info->cache,0,(size_t) nexus_info->length);
+        (void) memset(nexus_info->cache,0,(size_t) length);
     }
   else
     {
-      nexus_info->mapped=MagickTrue;
-      nexus_info->cache=(Quantum *) MapBlob(-1,IOMode,0,(size_t)
-        nexus_info->length);
+      nexus_info->cache=(Quantum *) MapBlob(-1,IOMode,0,(size_t) length);
+      if (nexus_info->cache != (Quantum *) NULL)
+        nexus_info->mapped=MagickTrue;
     }
   if (nexus_info->cache == (Quantum *) NULL)
     {
@@ -4987,31 +4990,10 @@
         cache_info->filename);
       return(MagickFalse);
     }
+  nexus_info->length=length;
   return(MagickTrue);
 }

-static inline MagickBooleanType IsPixelCacheAuthentic(
-  const CacheInfo *magick_restrict cache_info,
-  const NexusInfo *magick_restrict nexus_info)
-{
-  MagickBooleanType
-    status;
-
-  MagickOffsetType
-    offset;
-
-  /*
-    Does nexus pixels point directly to in-core cache pixels or is it buffered?
-  */
-  if (cache_info->type == PingCache)
-    return(MagickTrue);
-  offset=(MagickOffsetType) nexus_info->region.y*cache_info->columns+
-    nexus_info->region.x;
-  status=nexus_info->pixels == (cache_info->pixels+cache_info->number_channels*
-    offset) ? MagickTrue : MagickFalse;
-  return(status);
-}
-
 static inline void PrefetchPixelCacheNexusPixels(const NexusInfo *nexus_info,
   const MapMode mode)
 {
@@ -5076,9 +5058,8 @@
           if (cache_info->metacontent_extent != 0)
             nexus_info->metacontent=(unsigned char *) cache_info->metacontent+
               offset*cache_info->metacontent_extent;
+          nexus_info->authentic_pixel_cache=MagickTrue;
           PrefetchPixelCacheNexusPixels(nexus_info,mode);
-          nexus_info->authentic_pixel_cache=IsPixelCacheAuthentic(cache_info,
-            nexus_info);
           return(nexus_info->pixels);
         }
     }
@@ -5090,34 +5071,26 @@
     length+=number_pixels*cache_info->metacontent_extent;
   if (nexus_info->cache == (Quantum *) NULL)
     {
-      nexus_info->length=length;
-      status=AcquireCacheNexusPixels(cache_info,nexus_info,exception);
+      status=AcquireCacheNexusPixels(cache_info,length,nexus_info,exception);
       if (status == MagickFalse)
-        {
-          nexus_info->length=0;
-          return((Quantum *) NULL);
-        }
+        return((Quantum *) NULL);
     }
   else
     if (nexus_info->length < length)
       {
         RelinquishCacheNexusPixels(nexus_info);
-        nexus_info->length=length;
-        status=AcquireCacheNexusPixels(cache_info,nexus_info,exception);
+        status=AcquireCacheNexusPixels(cache_info,length,nexus_info,exception);
         if (status == MagickFalse)
-          {
-            nexus_info->length=0;
-            return((Quantum *) NULL);
-          }
+          return((Quantum *) NULL);
       }
   nexus_info->pixels=nexus_info->cache;
   nexus_info->metacontent=(void *) NULL;
   if (cache_info->metacontent_extent != 0)
     nexus_info->metacontent=(void *) (nexus_info->pixels+
-      (cache_info->number_channels*number_pixels));
+      cache_info->number_channels*number_pixels);
+  nexus_info->authentic_pixel_cache=cache_info->type == PingCache ?
+    MagickTrue : MagickFalse;
   PrefetchPixelCacheNexusPixels(nexus_info,mode);
-  nexus_info->authentic_pixel_cache=IsPixelCacheAuthentic(cache_info,
-    nexus_info);
   return(nexus_info->pixels);
 }

@@ -5766,7 +5739,7 @@
           length=extent;
           rows=1UL;
         }
-      q=cache_info->pixels+offset*cache_info->number_channels;
+      q=cache_info->pixels+cache_info->number_channels*offset;
       for (y=0; y < (ssize_t) rows; y++)
       {
         (void) memcpy(q,p,(size_t) length);
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: identify coredumps since 7.0.8-21

Post by magick »

Can you try -23, the latest release? Does identify work with this release?
freakout
Posts: 6
Joined: 2013-01-04T04:31:07-07:00
Authentication code: 6789

Re: identify coredumps since 7.0.8-21

Post by freakout »

yes - -23 is working - thank you so much
Post Reply