Issue with GM through JNI

Tianyu Lang <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.help
Message-ID <CABR2W4-w633GSVi2E4w0jB2TaXMsriK_+Y2VsW8cb14FpxCkqA@mail.gmail.com>
Hi GraphicsMagick masters,

In my program I am using GM 1.3.26 through JNI (Java Native Interface).
Unfortunately, it seems initializing GM by calling "
InitializeMagick(nullptr)" will corrupt the heap (or stack) and crash my
Java program.

Here is a snippet of my main function. GMImage.initContext is a static
function that only calls InitializeMagick(nullptr):

public static void main(String[] args) throws Exception {
    try {
      GmImage.initContext();

      ImageTranscoderConfig config = new ImageTranscoderConfig();

      final OstrichStatsReceiver statsReceiver = new
OstrichStatsReceiver(Stats.get(""));

      s3Utils = new S3Utils(new AmazonS3Client());

At the line "s3Utils = ", the program will crash due to segfault inside
JVM.

I have tried replacing GM JNI stuff with ImageMagick JNI, and with IM, the
program functions correctly. So I think it might not be the issue with my
JNI wrapper or my Java code.

As a result, I suspect the problem lies in InitializeMagick. Could you
please give me some pointers on how I can debug this issue? Is there
anything special that GM does at initialization time I should pay attention
to? I also tried building with openmp disabled in case there is conflict
between threading libraries.

Here are the functions involved on the GM side:

public static void initContext() throws Exception {
  initNative();
}

private static native void initNative() throws GmJniException;

JNIEXPORT void JNICALL Java_com_mediacommons_image_gm_GmImage_initNative(

    JNIEnv* env, jclass jcls) {
        InitializeMagick(nullptr);
}

Thank you,
Tianyu

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

_______________________________________________
Graphicsmagick-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/graphicsmagick-help
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.