On Thu, 27 Jan 2011, Reuben Thomas wrote:

On 27 January 2011 16:22, Bob Friesenhahn <bfrie...@simple.dallas.tx.us> wrote:
This bug does look ugly.  It seems that you are using a version of Ubuntu
which offers a newer GraphicsMagick than the one 10.04 is offering (10.04
only offers 1.3.5-6).  On the Ubuntu I have here, I see a package called
'graphicsmagick-dbg' which may offer the debug libraries you are looking
for.  The package is not named using the same conventions as the debug
symbols for other libraries.

Thanks; I assumed that package contained debug symbols only for
graphicsmagick-bin, but on looking at the file list, you're quite
right. So I now have some updated backtraces:

lt-psiconv: magick/semaphore.c:526: LockSemaphoreInfo: Assertion
`semaphore_info->signature == 0xabacadabUL' failed.

I downloaded the psiconv 0.9.8 source code and took a look at it. While I do not have sufficient time available to debug this issue, it is clear to see that psiconv is sophisticated enough (e.g puts Magick Images in list containers) that it could be causing this bug. It is best not to be lulled into feeling that the bug must be in GraphicsMagick because GraphicsMagick detected it. GraphicsMagick operates on a hair-trigger and is riddled with assert statements so it usually tells the programmer when something is wrong.

The part of the code which has gone wrong can happen if the blob I/O handler reference count is wrong. In an Image list, all of the Image list members contain a pointer to a shared blob (a wrapper for the file being read or written). This aspect is fragile, and likely bad design, but there is nothing to be done about it without substantially changing the API design.

There is a reason why newer GraphicsMagick may be detecting this problem when older one did not. Older GraphicsMagick used a "use is initialization" model so if the semaphore was deallocated (and pointer set to zero), the next access to it would simply allocate a new one. With newer GraphicsMagick, once the semaphore is deallocated it won't be resurrected just because code accessed it. The resurrection of deallocated semaphores tended to hide double-free type bugs. The newer approach is more rigorous and is also more reliable and efficient in multi-threaded programs. Now InitializeMagick() initializes every pre-defined (i.e. semaphore pointer in static location) semaphore in the implementation before it returns. Also, all semaphores in structures are allocated when the structure is allocated.

Bob
--
Bob Friesenhahn
bfrie...@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/

Reply via email to