[Magick-bugs] I've a problem with the Pixel Cache and SIGSEGV

Michael Kane miketeckia at gmail.com
Fri Sep 14 10:05:59 PDT 2007


Hi,

I'm working on an application that takes raw images from a Prosilica
GC-1600-C (using the prosilica SDK) and places them into a
multi-part/replace stream.  However, I seem to be plauged by the below
problem.  The camera's driver is getting a pointer to a callback function,
which calls the method that uses Magick++'s image and Blob classes to get
the output onto the stream.  The Prosilica camera's driver is multi-threaded
and frames arrive asyncronously (but really in sync for the most part).  Any
thoughts?

Source of Libraries: Fedora Extras Repository
Version of ImageMagick
Version of Magick++

------------------------------------------------------------------------------------------------------------------------------
Streamer.cgi: magick/cache.c:2383: GetNexus: Assertion
`cache_info->number_views
 != 0UL' failed.

Program received signal SIGABRT, Aborted.
[Switching to Thread -1371313264 (LWP 10631)]
0x00110402 in __kernel_vsyscall ()
(gdb) bt
#0  0x00110402 in __kernel_vsyscall ()
#1  0x009f9ba0 in raise () from /lib/libc.so.6
#2  0x009fb4b1 in abort () from /lib/libc.so.6
#3  0x009f31db in __assert_fail () from /lib/libc.so.6
#4  0x00739a2b in GetNexus () from /usr/lib/libMagick.so.10
#5  0x00742265 in OpenCacheView () from /usr/lib/libMagick.so.10
#6  0x00162f7e in Magick::Pixels::Pixels () from /usr/lib/libMagick++.so.10
#7  0x0804ab9f in StreamingVideo::ProsilicaFrameRenderer::outputImage (
    this=0xbfc67784, pFrame=0xbfc6779c, format=@0xae4362c8)
    at Prosilica/ProsilicaFrameRenderer.cpp:36
#8  0x0804afa3 in StreamingVideo::ProsilicaFrameRenderer::frameDoneCB (
    this=0xbfc67784, pFrame=0xbfc6779c)
    at Prosilica/ProsilicaFrameRenderer.cpp:153
#9  0x0804b242 in StreamingVideo::MarshalFrameDoneCB ()
#10 0x00266c87 in pPvRawCamera::HandleFrameDone () from ./libPvAPI.so
#11 0x0022f98f in cPvFrameLooper::Looping () from ./libPvAPI.so
#12 0x00264a91 in pPvLooper::Body () from ./libPvAPI.so
#13 0x002707ac in _ThreadFunction () from ./libPvAPI.so
#14 0x0036645b in start_thread () from /lib/libpthread.so.0
#15 0x00a9f23e in clone () from /lib/libc.so.6
(gdb)
----------------------------------------------------------------------------------------------------------------------
The Following is the bulk of the work that is related to
ImageMagick/Magick++.

void ProsilicaFrameRenderer::outputImage(tPvFrame* pFrame, string format) {
    Image image;
    image.size(Geometry(pFrame->Width, pFrame->Height));//Make an image
canvas the size of our frame
    //OK, now the fun...  We're Going to write each pixel in
pFrame->ImageBuffer to the
    //canvas directly!!!
    unsigned int nPixels = pFrame->ImageSize;//WARNING, This is in Bytes =>
1 Pixel => 24 Bits
    unsigned char * buff = static_cast<unsigned char*>(pFrame->ImageBuffer);
    image.depth(24);
    unsigned int w, h;
    w = pFrame->Width;
    h = pFrame->Height;
    clog << "Bitdepth: " << pFrame->BitDepth << endl;
    image.colorSpace(RGBColorspace);
    image.modifyImage();
    Pixels pix_cache(image);//<-------------------- Dies here
    int startx, starty, sizex, sizey;
    startx = starty = 0;
    sizex = pFrame->Width;
    sizey = pFrame->Height;
    PixelPacket *pixels;
    pixels = pix_cache.get(startx, starty, sizex, sizey);

    for(register unsigned int i = 0; i < nPixels; i+=3) {//hint hint CPU...
         //
         // Ok, we are processing an array of pixels that basically looks
like
         // rowrowrowrowrow...
         // OK, the camera is sending 24 bits per pixel....
         // This means
         // Gamma = 1.0
         // COlors are 8-bits wide
         // R is in front 8 bits => 1 Chars
         // G is in middle 8 bits => 1 Chars
         // B is in last 8 bits => 1 Chars
         //
         //image.pixelColor(i % pFrame->Width, i / pFrame->Width,
Color(((unsigned int)buff[i]), ((unsigned int)buff[i+1]), ((unsigned
int)buff[i+2]), 100));
         *(pixels++) = Color(((unsigned int)buff[i]), ((unsigned
int)buff[i+1]), ((unsigned int)buff[i+2]), 100);
    }
    pix_cache.sync();
    cout << "Apply format Transform" << endl;
    image.magick(format);
    cout << "PRepare blob..." << endl;
    Blob outBlob;
    image.write(&outBlob);
    cout << "Blob written..." << endl;
    cout.write(static_cast<const char*>(outBlob.data()), outBlob.length());
}


Thanks for the help,


-- 
Michael


More information about the Magick-bugs mailing list