Consider the following code
{{{
    FILE *fh;
    FILE *p;
    char *buf;
    size_t result;
    long fsize;

    fh = fopen("demo.pgm", "rb");

    // allocate buffer to hold file
    fseek(fh, 0, SEEK_END);
    fsize = ftell(fh);
    rewind(fh);
    buf = (char*) malloc(sizeof(char)*fsize);

    // read from the source file
    result = fread(buf, 1, fsize, fh);
    printf("result: %d\n", result);
    fclose(fh);

    // pipe to convert and write to png
    p = popen("convert pgm:- out.png", "w");
    //p = popen("cat - > out.pgm", "w");
    fwrite(buf, 1, fsize, p);
    pclose(p);
    free(buf);
}}}

Run as:
$ dmtcp_launch ./test_convert

It basically loads a file into memory, then pipes it into the convert
function via popen and stdin.

This segment runs fine outside of DMTCP, but segfaults inside.

An examination of the core dump is interesting.

$ gdb /usr/bin/convert core.31830

(gdb) bt
#0  0x00000034ec00f6ab in raise (sig=11) at
../nptl/sysdeps/unix/sysv/linux/pt-raise.c:42
#1  0x0000003a37914e3f in MagickSignalHandler (signal_number=11) at
magick/magick.c:1168
#2  <signal handler called>
#3  0x00000034ec40142e in __dlerror () at dlerror.c:95
#4  0x00000034fde06685 in ?? () from /usr/lib64/libltdl.so.7
#5  0x00000034fde03986 in lt_dlsym () from /usr/lib64/libltdl.so.7
#6  0x0000003a37919965 in OpenModule (module=<value optimized out>,
exception=0x224d590)
    at magick/module.c:1293
#7  0x0000003a379151f3 in GetMagickInfo (name=0x7ffcd0f386a0 "PGM",
exception=0x224d590)
    at magick/magick.c:442

So, it is attempting to dynamically load the module to process the PGM
file.  Bad things appear to start near lt_dlsym, where a __dlerror is
thrown.

I'm happy to do some further testing, and the above example should allow
you to test on your own  as well. If PGM is a weird input for you, I've
reproduced the error using PNG inputs, so it does not appear specific to
that library, but that the dynamic loader is pretty consistently failing.


-- 
-Kyle
------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
Dmtcp-forum mailing list
Dmtcp-forum@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dmtcp-forum

Reply via email to