Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to construct outgoing method call: Primative array being sent as non-primative array. #8

Closed
bertrik opened this issue Feb 20, 2018 · 5 comments

Comments

@bertrik
Copy link

bertrik commented Feb 20, 2018

I'm happy to see the original dbus-java library being continued in this library and seeing active development on it. Can you give me your thoughts on the following:

I sometimes get an exception like this one, when doing a method call from Java to a C application:
"org.freedesktop.dbus.exceptions.DBusExecutionException: Failed to construct outgoing method call: Primative array being sent as non-primative array."
The method I invoke, looks like this: "int frameTransmit(byte[] frame);"
I'm a bit puzzled because this only happens ocassionally, not consistently. I'm starting to suspect some kind of multi-threading issues perhaps.

The exception message appears to originate in Message.java#683. As I understand this happens before invoking the remote method, when the signature of an array argument to the method to be called is checked. Apparently it cannot find a specifier for a primitive type in this signature.

Could this indeed be some kind of multi-threading race condition?
In a future version, can you perhaps update the exception message to include the offending type specifier in the signature? Also perhaps update the spelling of the word primitive?

@hypfvieh
Copy link
Owner

Hmm... I'm not sure wether it is a race condition or some other kind of bug. Most of the code is still like it was ten years ago. I just added some generics.

Line 683 in Message.java is a type cast from List to Object[], it is in deed an array of Object, so a cast to a primitive array is not possible. I wonder why it is getting to that line. When you use a byte[], data should not be a List instance.

To get the root cause from all of this, can you please post the complete stacktrace?
Sample code would also be great, but the stacktrace will also help a lot.

@bertrik
Copy link
Author

bertrik commented Feb 22, 2018

I mean it might be some kind of race/multithreading problem in my own code.

Line 683 in my Message.java (from release 2.7.4 not the git version) shows the exception:
throw new MarshallingException(t("Primative array being sent as non-primative array."));

I don't have much of a stacktrace. This is what I have (please note this is from release 2.7.4):
org.freedesktop.dbus.exceptions.DBusExecutionException: Failed to construct outgoing method call: Primative array being sent as non-primative array.
at org.freedesktop.dbus.RemoteInvocationHandler.executeRemoteMethod(RemoteInvocationHandler.java:134)
at org.freedesktop.dbus.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:234)
at com.sun.proxy.$Proxy13.frameTransmit(Unknown Source)
at nl.technolution.flowmeter.dbus.DbusGdcModule.sendFrame(DbusGdcModule.java:56)

@hypfvieh
Copy link
Owner

Race condition in your code is also possible :)

I've made a small test on my system using a DBus server written with dbus-java and a client also with dbus-java, sending around 100000 messages in a row as (primitive) byte array without any kind of DbusException.

Also it does not make sense to me, that it fails in line 683.
For the code it looks like your data object given to the method is of type List.

I can only imagine two possible causes:

  • "data" reference is changed to List by another thread while Message.class is already processing the data (missing synchonize?)
  • you use libraries like fastutil or trove which provide primitive maps and lists which are compatible with List interface but return byte[] if you call 'toArray' (this cannot be casted to Object[])

@bertrik
Copy link
Author

bertrik commented Mar 12, 2018

Are we looking at the same code?

My Message.java line 683 says
throw new MarshallingException(t("Primative array being sent as non-primative array."));

This is from dbus-java-2.7.4.jar

@hypfvieh
Copy link
Owner

Sorry I looked in a newer version.

Anyways...
the given data object seems to be an array of a primitive type, but not of any type handled in the switch statement.

I can't help here. You should try to debug this part, so you get an idea which type is used here (check what ArgumentType sigb[i] contains).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants