Error when calling some methods

Jan 19, 2012 at 11:57 AM

Hi,

I've been using this library successfully (compiled for 64 bit) until I notice that if I call Queue.sendBytes() I get an error from the Java VM.

#

# A fatal error has been detected by the Java Runtime Environment:

#

#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000006da48ad7, pid=6652, tid=1760## JRE version: 6.0_24-b07

# Java VM: Java HotSpot(TM) 64-Bit Server VM (19.1-b02 mixed mode windows-amd64 compressed oops)# Problematic frame:# V  [jvm.dll+0x258ad7]## An error report file with more information is saved as:

# hs_err_pid6652.log

#

# If you would like to submit a bug report, please visit:#   http://java.sun.com/webapps/bugreport/crash.jsp#

 

Using Queue.send(Message) everything goes as expected. Am I missing something here or is it a known issue?

Best regards,

Rui

Coordinator
Jan 19, 2012 at 7:57 PM

I wouldn't say it's a "known issue".

When I wrote the library I did not have a 64-bit machine to compile and test on. I suppose the problem is related to data sizes in the C-code function that backs Queue.sendBytes().  Have you looked at that code?

 

Coordinator
Jan 19, 2012 at 8:05 PM

On first examination, I'd guess it has to do with the thunking function, Java_ionic_Msmq_Queue_nativeSendBytes .'

For one thing: this function does strlen() calls and stores them in an int, which I think is wrong.  It needs to be stored into a size_t.

There may be other problems in that function, too.  You should have seen a warning during the 64-bit compile of this code, for this problem. You should see warnings if there are any other problems, too. 

Maybe go over your compile output again.

As I said, I never compiled this on 64-bit, so I don't know the answer here.

 

Jan 19, 2012 at 8:11 PM

Hi,

I know a bit of C but it is a bit complicated for me to quickly understand how that API works. But, I took a look at your code and I notice that both Queue.send(Message) and Queue.send(bytes[]) [sorry about the typo earlier on the method name] use the same nativeSendBytes method so my guess is that you're calling nativeSendBytes differently one from another, i.e. maybe it has to do with the way you're filling up the arguments.

I'll try to look at the compile output, but I can only to that next week.

Jan 20, 2012 at 10:31 AM

I took a look at the "problem" and when you use Queue.send(byte[]) or Queue.send(String) you call the native method with a null correlationId. If you change that to "new byte[0]" it will stop the error. Also I want to talk you about one other thing. I believe that using only the java.library.path variable to point to the libraries is not a good practice. Imagine that you're using this library in an application server and you cannot change the JVM properties? Also, imagine that in the same JVM you have to point to two different locations. So I propose something like the following:

    private static boolean initialised = false;

    public static void initSystemLibraries(String... libs) {
        if (initialised) {
            return;
        }

        if (libs.length == 0) {
            System.loadLibrary("MsmqJava");
        } else {
            for (String f : libs) {
                System.load(f);
            }
        }

        nativeInit();
        initialised = true;
    }

 

The _init() method should call this method without any arguments so the array remains zero length. But if someone wants to initialise the library by itself then it should call Queue.initSystemLibraries() with the libraries needed, in this case only one.

What do you think?

One other thing I think it would come very handy would be the possibility to retrieve the date of an incoming message.

Best regards,

Rui

Feb 20, 2012 at 10:29 PM

Hi,

 

Could you please provide us how you compiled with 64 bit?

 

Thanks,

Raja

Coordinator
Feb 20, 2012 at 10:57 PM
Hi,
I don’t believe I’ve ever compiled that library for 64 bit.
All the source code I used is in the download.
-Dino
From: [email removed]
Sent: Monday, February 20, 2012 2:30 PM
To: [email removed]
Subject: Re: Error when calling some methods [MsmqJava:286659]

From: raja84

Hi,

Could you please provide us how you compiled with 64 bit?

Thanks,

Raja