Possible bug in 6.0.7? Need help finding the problem.

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
mankyd

Possible bug in 6.0.7? Need help finding the problem.

Post by mankyd »

I've been staring at this bug for 2 hours now. I am beginning to think maybe its a bug in the ImageMagick code somewhere. I am getting an assertion failure in 'image.c' in the CloneImage function on line 896. I am running Centos4, ImageMagick++ version 6.0.7.1-16 (the most recent release available in my repository.) What's really bugging me is that this code works just fine on my Gentoo box that runs ImageMagick 6.3.

Here is a snippet of the code that's causing the problem. 'tiles' is a list of class 'tile' that contains x and y coords as well as an image. Each tile is supposed to be drawn into 'out' at the coords it specifies:

Code: Select all

int prev_id = 0;
tile *tl = NULL;
list<Drawable> ts;

for (tiles_it = tiles.begin(); tiles_it != tiles.end(); tiles_it++) {
	//if we've come upon a new tile
	//draw out any waiting images and load up the new tile
	if ((*tiles_it).id() != prev_id) {

		if (ts.empty() == false) {
/**************
out.draw(ts) is the line that fails!
**************/
			out.draw(ts);
			ts.clear();
		}
		prev_id = (*tiles_it).id();

		//unload the image now that we're done with it
		if (tl != NULL)
			tl->remove_image(base_size);

		tl = &(*tiles_it);
	}

	//add the current tile to the list of images to be drawn
	try {
		//I have verified that tl->get_image() is indeed working
		//it returns a reference to an Image that is supposed to 
		//be drawn
		ts.push_back(DrawableCompositeImage((*tiles_it).x() * base_size, (*tiles_it).y() * base_size, tl->get_image(base_size)));
	} catch (exception &e) {
		throw;
	}
}
I have been able to identify the assertion error as this line of code in image.c, in the function CloneImage:

Code: Select all

assert(image != (const Image *) NULL);
Thanks for any help you might be able to offer!
mankyd

Post by mankyd »

Well, I've sort of solved this problem, sub-optimally. I still think there may be a bug in the 6.0.7 release that is marked as stable on Centos/RH (supposedly they back port bug fixes, but I don't know anything about that really.)

Here's what I did. First, I tried drawing the DrawableCompositeImage out immediately to 'out', avoiding the whole list:

Code: Select all

//commented out this line
//ts.push_back(DrawableCompositeImage((*tiles_it).x() * base_size, (*tiles_it).y() * base_size, tl->get_image(base_size)));
//added this line
out.draw(DrawableCompositeImage((*tiles_it).x() * base_size, (*tiles_it).y() * base_size, tl->get_image(base_size)));
This gives me the same assertion failure as before, however. So instead I tried composite():

Code: Select all

out.composite(tl->get_image(base_size), (*tiles_it).x() * base_size, (*tiles_it).y() * base_size, OverCompositeOp);
This works, yay! But is it less than optimal? I am no longer compositing images en masse by way of a list.
Post Reply