vusonbmt / rosjava

Automatically exported from code.google.com/p/rosjava
0 stars 0 forks source link

java.lang.NegativeArraySizeException deserializing sensor_msgs/NavSatFix #121

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add a listener to the gps topic:
Subscriber<sensor_msgs.NavSatFix> subscriber =
                node.newSubscriber(topic, "sensor_msgs/NavSatFix");
        subscriber.addMessageListener(new MessageListener<sensor_msgs.NavSatFix>() {

            @Override
            public void onNewMessage(sensor_msgs.NavSatFix message) {
System.out.println("Never comes here");

        });
2. Receive first message

What is the expected output? What do you see instead?
I expect the message to be parsed correctly

What version of the product are you using? On what operating system?
Checked out last friday (15.6.2012)and rebuilt the whole thing. Sensor messages 
where flagged to be rebuilt. Using ubuntu 11.10. (oneiric). Using gpsd_client 
from the repository, command line is:
rosrun gpsd_client gpsd_client  _use_gps_time:=false.
The messages from gspd_client do not look suspicious.

Please provide any additional information below.
I will attach you a stack trace at the end. 
The message gets parsed, in Default message serializer, some fields get parsed:

for (Field field : message.toRawMessage().getFields()) {
      if (!field.isConstant()) {
        field.deserialize(buffer);
      }
    }
but one field causes the error.

After some NegativeArraySizeExceptions, it switches to "Not enough heap space". 

If I can do sth. to help, please feel free to ask. 

Felix. 

Stack trace:

18.06.2012 09:42:42 org.jboss.netty.channel.DefaultChannelPipeline
WARNUNG: An exception was thrown by a user handler while handling an exception 
event ([id: 0x510afb13, /10.10.10.17:33103 :> moby/10.10.10.17:57580] 
EXCEPTION: java.lang.NegativeArraySizeException)
org.ros.exception.RosRuntimeException: java.lang.NegativeArraySizeException
    at org.ros.internal.transport.ConnectionTrackingHandler.exceptionCaught(ConnectionTrackingHandler.java:73)
    at org.jboss.netty.channel.Channels.fireExceptionCaught(Channels.java:432)
    at org.jboss.netty.channel.AbstractChannelSink.exceptionCaught(AbstractChannelSink.java:52)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:302)
    at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:317)
    at org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:299)
    at org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:216)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:274)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:261)
    at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:349)
    at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:280)
    at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:200)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NegativeArraySizeException
    at org.ros.internal.message.DoubleArrayField.deserialize(DoubleArrayField.java:67)
    at org.ros.internal.message.DefaultMessageDeserializer.deserialize(DefaultMessageDeserializer.java:47)
    at org.ros.internal.transport.IncomingMessageQueue$Receiver.messageReceived(IncomingMessageQueue.java:66)
    ... 12 more

Original issue reported on code.google.com by lord.kil...@googlemail.com on 18 Jun 2012 at 7:55

GoogleCodeExporter commented 9 years ago
Perhaps this is helpful: 
The generated source looks like:
package sensor_msgs;

public interface NavSatFix extends org.ros.internal.message.Message {
  static final java.lang.String _TYPE = "sensor_msgs/NavSatFix";
  static final java.lang.String _DEFINITION = "# Navigation Satellite fix for any Global Navigation Satellite System\n#\n# Specified using the WGS 84 reference ellipsoid\n\n# Header specifies ROS time and frame $
  static final byte COVARIANCE_TYPE_UNKNOWN = 0;
  static final byte COVARIANCE_TYPE_APPROXIMATED = 1;
  static final byte COVARIANCE_TYPE_DIAGONAL_KNOWN = 2;
  static final byte COVARIANCE_TYPE_KNOWN = 3;
  std_msgs.Header getHeader();
  void setHeader(std_msgs.Header value);
  sensor_msgs.NavSatStatus getStatus();
  void setStatus(sensor_msgs.NavSatStatus value);
  double getLatitude();
  void setLatitude(double value);
  double getLongitude();
  void setLongitude(double value);
  double getAltitude();
  void setAltitude(double value);
  double[] getPositionCovariance();
  void setPositionCovariance(double[] value);
  byte getPositionCovarianceType();
  void setPositionCovarianceType(byte value);
}

The message definition of sensor_msgs/NavSatFix is

uint8 COVARIANCE_TYPE_UNKNOWN=0
uint8 COVARIANCE_TYPE_APPROXIMATED=1
uint8 COVARIANCE_TYPE_DIAGONAL_KNOWN=2
uint8 COVARIANCE_TYPE_KNOWN=3
Header header
    uint32 seq
    time stamp
    string frame_id
NavSatStatus status
    int8 STATUS_NO_FIX=-1
    int8 STATUS_FIX=0
    int8 STATUS_SBAS_FIX=1
    int8 STATUS_GBAS_FIX=2
    uint16 SERVICE_GPS=1
    uint16 SERVICE_GLONASS=2
    uint16 SERVICE_COMPASS=4
    uint16 SERVICE_GALILEO=8
    int8 status
    uint16 service
float64 latitude
float64 longitude
float64 altitude
float64[9] position_covariance
uint8 position_covariance_type

Original comment by lord.kil...@googlemail.com on 18 Jun 2012 at 8:29

GoogleCodeExporter commented 9 years ago
A standard message (rostopic echo /fix):

---
header: 
  seq: 4478
  stamp: 
    secs: 1340008262
    nsecs: 233342741
  frame_id: ''
status: 
  status: 0
  service: 1
latitude: 37.86106
longitude: 9.877675
altitude: 191.7
position_covariance: [16.677, 0.0, 0.0, 0.0, 20.312, 0.0, 0.0, 0.0, 37.521]
position_covariance_type: 2
---

Original comment by lord.kil...@googlemail.com on 18 Jun 2012 at 8:32

GoogleCodeExporter commented 9 years ago
The problematic field is the position covariance (DoubleArrayField<FLOAT64, 
position_covariance>) :
 public void deserialize(ByteBuffer buffer) {
    int size = buffer.getInt();
    value = new double[size];
    for (int i = 0; i < size; i++) {
      value[i] = (Double) type.deserialize(buffer);
    }
 }

size (== buffer.getInt() varies, is very big: 584115552  (as example), 
1065151889
if it is too big, it causes a heap space error.
i also found negative sizes: 
-1236950581

So what could be the problem? The message is not as expected? 

Original comment by lord.kil...@googlemail.com on 18 Jun 2012 at 8:51

GoogleCodeExporter commented 9 years ago
buffer.getInt() should return 9 ?

Original comment by lord.kil...@googlemail.com on 18 Jun 2012 at 8:53

GoogleCodeExporter commented 9 years ago
Same here. I have the exact problem except while trying to receive the 
nav_msgs.Odometry message type. My code is essentially the same as OP, with the 
different message types.

Original comment by blairgag...@gmail.com on 21 Jun 2012 at 12:00

GoogleCodeExporter commented 9 years ago

Original comment by damonkoh...@google.com on 5 Jul 2012 at 8:24