Possible race condition?
Posted: 2009-10-03T05:14:25-07:00
Testing the following imagick code I get an occasional segfault:
The backtrace looks like following:
Testing the almost the same thing in MagickWand code does NOT segfault:
After this I tested the Imagick code with ImageMagick compiled with --disable-openmp and it does not segfault.
Code: Select all
<?php
$combined = new Imagick();
$combined->readImage("floodfillpaint_intermediate.jpg");
/* The target pixel to paint */
$x = 1;
$y = 1;
/* Get the color we are painting */
$target = $combined->getImagePixelColor($x, $y);
/* Paint */
$combined->floodfillPaintImage("black", 1, $target, $x, $y, false);
/* Save the result */
$combined->writeImage("floodfillpaint_result.jpg");
Code: Select all
0x00007ff25fa76d6e in ?? () from /usr/lib/libgomp.so.1
(gdb) bt
#0 0x00007ff25fa76d6e in ?? () from /usr/lib/libgomp.so.1
#1 0x00007ff25fa75846 in ?? () from /usr/lib/libgomp.so.1
#2 0x00007ff262023f9a in start_thread () from /lib/libpthread.so.0
#3 0x00007ff26295156d in clone () from /lib/libc.so.6
#4 0x0000000000000000 in ?? ()
(gdb)
Code: Select all
#include <stdio.h>
#include <wand/MagickWand.h>
int main() {
MagickWand *image;
PixelWand *source, *target;
MagickWandGenesis();
image = NewMagickWand();
source = NewPixelWand();
target = NewPixelWand();
MagickReadImage(image, "floodfillpaint_intermediate.jpg");
PixelSetColor(source, "red");
PixelSetColor(target, "black");
MagickGetImagePixelColor(image, 1, 1, source);
MagickFloodfillPaintImage(image, DefaultChannels, target, 1, source, 1, 1, MagickFalse);
MagickWriteImage(image, "result.jpg");
DestroyMagickWand(image);
DestroyPixelWand(source);
DestroyPixelWand(target);
MagickWandTerminus();
return 0;
}