Page 1 of 1

MagickToMime bug

Posted: 2007-01-20T15:48:19-07:00
by rmabry
The PerlMagick MagickToMime method crashes, at least in the 6.3.2 Beta I grabbed yesterday.

I freed my version of the offending free() call at line 5200 in Magick.xs and mine/mime now seems well.

Code: Select all

# free(mime);
Rick

Posted: 2007-01-20T19:32:03-07:00
by magick
Can you generate a stack trace for us? We tried to reproduce the problem but MagickToMime() works for us.

Posted: 2007-01-20T20:08:03-07:00
by rmabry
magick wrote: Can you generate a stack trace for us? We tried to reproduce the problem but MagickToMime() works for us.


I should have mentioned that this is on Windows, compiled with VC++7 from ImageMagick-6.3.2-1-windows.zip (Beta); perl, v5.8.8 built for MSWin32-x86-multi-thread.

I executed the following script.

Code: Select all

#!/usr/bin/perl -- 
use Image::Magick;
$image = new Image::Magick;
# $image->Read("logo:");
$m = $image->MagickToMime('tif');
The result was this:

Free to wrong pool 222770 not fdfdfdfd at mimetest.plx line 5.


Here's what the debugger spewed:

Unhandled exception at 0x28085bae in perl.exe: 0xC0000005: Access violation writing location 0x00000000.

perl58.dll!28085bae()
perl58.dll!2808682e()
> Magick.dll!XS_Image__Magick_MagickToMime(interpreter * my_perl=0x00224394, cv * cv=0x00224fa8) Line 5173 C
perl58.dll!28040019()
perl58.dll!2805d49d()
perl58.dll!28023fdf()
perl58.dll!28023e96()
perl58.dll!28023d3f()
perl58.dll!28088a12()
perl58.dll!28088a21()
ntdll.dll!7c9131dc()
ntdll.dll!7c913281()
ntdll.dll!7c913288()
ntdll.dll!7c9106eb()
msvcrt.dll!77c2c3c9()
msvcrt.dll!77c2c3ce()
ntdll.dll!7c910992()
msvcrt.dll!77c2c3ce()
msvcrt.dll!77c2c3e7()
msvcrt.dll!77c2c42e()
msvcrt.dll!77c3ac5f()
perl.exe!00401012()
perl.exe!004010f9()
kernel32.dll!7c816fd7()


The debugger displayed the following hunk of code, the cursor at the marked line:

Code: Select all

#line 5194 "Magick.xs"
  {
    char
      *mime;

    mime=MagickToMime(name);
    RETVAL=newSVpv(mime,0);
  free(mime);
  }
#line 5173 "Magick.c"
	ST(0) = RETVAL;    # <------------------
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}
I hope this is helpful.

Rick

Posted: 2007-01-21T11:26:01-07:00
by magick
Change
  • free(mime);
to
  • mime=(char *) RelinquishMagickMemory(mime);

Posted: 2007-01-21T12:31:21-07:00
by rmabry
magick wrote: Change
  • free(mime);
to
  • mime=(char *) RelinquishMagickMemory(mime);


That does it - thanks.

Rick