magick/semaphore.c:288: LockSemaphoreInfo: Assertion `semaph

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
mkoppanen
Posts: 309
Joined: 2007-06-09T07:06:32-07:00

magick/semaphore.c:288: LockSemaphoreInfo: Assertion `semaph

Post by mkoppanen »

Hello,

found the following issue in the latest ImageMagick source package. Not sure when this was introduced:

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <wand/MagickWand.h>

int main(int argc,char **argv)
{
  MagickWandGenesis();
  MagickWandTerminus();
  return(0);
}

Code: Select all

# gdb --args ./wand
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu"...
(gdb) run
Starting program: /tmp/trunk/wand 
[Thread debugging using libthread_db enabled]
wand: magick/semaphore.c:290: LockSemaphoreInfo: Assertion `semaphore_info != (SemaphoreInfo *) ((void *)0)' failed.
[New Thread 0x7f34247137a0 (LWP 12908)]

Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7f34247137a0 (LWP 12908)]
0x00007f34211a1d25 in raise () from /lib/libc.so.6
(gdb) bt
#0  0x00007f34211a1d25 in raise () from /lib/libc.so.6
#1  0x00007f34211a4de1 in abort () from /lib/libc.so.6
#2  0x00007f342119af99 in __assert_fail () from /lib/libc.so.6
#3  0x00007f3423efc4cf in LockSemaphoreInfo (semaphore_info=0x0) at magick/semaphore.c:290
#4  0x00007f34242f4b90 in DestroyWandIds () at wand/wand.c:116
#5  0x00007f34242a8db9 in MagickWandTerminus () at wand/magick-wand.c:994
#6  0x0000000000400785 in main ()
Note: the line numbers might be a bit off in this one. The magick/semaphore.c should be 288.


It seems that the semaphore info gets allocated when first MagickWand instance is created. This patch seems to fix the issue but I am not sure if it's 100% right thing to do:

Code: Select all

Index: wand/wand.c
===================================================================
--- wand/wand.c (revision 510)
+++ wand/wand.c (working copy)
@@ -113,12 +113,15 @@
 */
 WandExport void DestroyWandIds(void)
 {
-  (void) LockSemaphoreInfo(wand_semaphore);
+  if (wand_semaphore != (SemaphoreInfo *)NULL)
+    (void) LockSemaphoreInfo(wand_semaphore);
   if (wand_ids != (SplayTreeInfo *) NULL)
     wand_ids=DestroySplayTree(wand_ids);
   instantiate_wand=MagickFalse;
-  (void) UnlockSemaphoreInfo(wand_semaphore);
-  DestroySemaphoreInfo(&wand_semaphore);
+  if (wand_semaphore != (SemaphoreInfo *)NULL) {
+    (void) UnlockSemaphoreInfo(wand_semaphore);
+    DestroySemaphoreInfo(&wand_semaphore);
+  }
 }
 

 /*
Index: ChangeLog
===================================================================
--- ChangeLog   (revision 510)
+++ ChangeLog   (working copy)
@@ -1,3 +1,6 @@
+2009-10-28  6.5.7-4 Mikko <mkoppanen@php.net>
+  * Fix assert error when no SemaphoreInfo is NULL
+  
 2009-10-28  6.5.7-3 Cristy  <quetzlzacatenango@image...>
   * Convert SVG clipping path points from unsigned to long.
 
Mikko Koppanen
My blog: http://valokuva.org
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: magick/semaphore.c:288: LockSemaphoreInfo: Assertion `semaph

Post by magick »

We have a patch in the Subversion trunk to fix the problem you reported, available by sometime tomorrow. Thanks.
pzeldin

Re: magick/semaphore.c:288: LockSemaphoreInfo: Assertion `semaph

Post by pzeldin »

I am still getting this in ImageMagick-6.5.7-6
I see that you added check for memory_semaphore == (SemaphoreInfo *) NULL in memory.c:DestroyMagickMemory() but not in AcquireMagickMemory()
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: magick/semaphore.c:288: LockSemaphoreInfo: Assertion `semaph

Post by magick »

Look for a patch in the Subversion trunk by sometime tomorrow. Thanks.
Snowman
Posts: 6
Joined: 2009-11-15T16:01:16-07:00
Authentication code: 8675309

Re: magick/semaphore.c:288: LockSemaphoreInfo: Assertion `semaph

Post by Snowman »

I'm still getting a semaphore error message in ImageMagick-6.5.7-9:

$ convert -version
Version: ImageMagick 6.5.7-9 2009-11-19 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC
Features: OpenMP

convert: magick/semaphore.c:220: DestroySemaphoreInfo: Assertion `(*semaphore_info) != (SemaphoreInfo *) ((void *)0)' failed.
Aborted
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: magick/semaphore.c:288: LockSemaphoreInfo: Assertion `semaph

Post by magick »

Post the output of
  • gdb convert
    run -version
    where
The stack trace will help us identify the source of the problem. BTW, convert -version works for us without complaint.
Snowman
Posts: 6
Joined: 2009-11-15T16:01:16-07:00
Authentication code: 8675309

Re: magick/semaphore.c:288: LockSemaphoreInfo: Assertion `semaph

Post by Snowman »

Here is the trace for the stripped binary. I could provide the trace of an unstripped binary if necessary.

Code: Select all

(gdb) where
#0  0x00007ffff6f99045 in raise () from /lib/libc.so.6
#1  0x00007ffff6f9a470 in abort () from /lib/libc.so.6
#2  0x00007ffff6f92141 in __assert_fail () from /lib/libc.so.6
#3  0x00007ffff795a235 in DestroySemaphoreInfo () from /usr/lib/libMagickCore.so.2
#4  0x00007ffff796460a in UnregisterStaticModules () from /usr/lib/libMagickCore.so.2
#5  0x00007ffff791b655 in MagickCoreTerminus () from /usr/lib/libMagickCore.so.2
#6  0x00000000004008bd in main ()
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: magick/semaphore.c:288: LockSemaphoreInfo: Assertion `semaph

Post by magick »

We can reproduce the problem you posted and will have a patch in the next point release of ImageMagick. Thanks.
Post Reply