Bug 1074005

Summary: java bindings inspect_list_applications2 throws java.lang.ArrayIndexOutOfBoundsException:
Product: Red Hat Enterprise Linux 6 Reporter: Richard W.M. Jones <rjones>
Component: libguestfsAssignee: Pino Toscano <ptoscano>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.6CC: huzhan, jherrman, leiwang, maarten.fonville, mbooth, ptoscano, rbalakri, wshi
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libguestfs-1.20.11-12.el6 Doc Type: Bug Fix
Doc Text:
In the Java binding, or APIs that return a list of objects different from String caused an ArrayIndexOutOfBoundsException exception to be triggered. The creation of the result list has been fixed, and these APIs now return the expected result.
Story Points: ---
Clone Of: 1073906 Environment:
Last Closed: 2015-07-22 05:55:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1073906    
Bug Blocks:    

Description Richard W.M. Jones 2014-03-07 16:12:50 UTC
+++ This bug was initially created as a clone of Bug #1073906 +++

Description of problem:

Using the inspect_list_applications2 function causes java.lang.ArrayIndexOutOfBoundsException to be thrown.

Version-Release number of selected component (if applicable):

libguestfs-java-1.25.42-1.fc21.x86_64

How reproducible:

100%

Steps to Reproduce:

Download InspectVM.java file attached.

Compile it like this:

javac -classpath /usr/share/java/libguestfs.jar InspectVM.java 

To test this you will need any Linux disk image.  eg. Build one using
virt-builder:

virt-builder fedora-20

Run the program on this disk image:

$ java -classpath /usr/share/java/libguestfs.jar:. InspectVM fedora-20.img 
Root device: /dev/sda3
  Product name: Fedora release 20 (Heisenbug)
  Version:      20.0
  Type:         linux
  Distro:       fedora
java.lang.ArrayIndexOutOfBoundsException: 231

It shouldn't print the ArrayIndexOutOfBoundsException error.

--- Additional comment from Maarten on 2014-03-07 08:24:57 EST ---

This same bug appears with a ubuntu guest machine.

Tewsted it with JDK Oracle 1.8 and multiple  libguestfs versions (up to 1.24.5)

--- Additional comment from Richard W.M. Jones on 2014-03-07 10:29:16 EST ---

Patches posted:
https://www.redhat.com/archives/libguestfs/2014-March/thread.html#00042

--- Additional comment from Richard W.M. Jones on 2014-03-07 11:04:26 EST ---

I pushed this series upstream, on the basis that:

 - passes make check

 - passes make check-valgrind [but valgrind probably isn't run on
   the java bindings, so this may not be meaningful]

 - should be at least an improvement on the previous situation, even
   if we discover further problems.

Therefore I'm closing this bug, fixed upstream in libguestfs >= 1.25.43.

These are candidates for backporting to the stable branch.

Please reopen if you find further problems with
g.inspect_list_applications2.  For other Java bindings bugs,
open a new bug.

Comment 1 Richard W.M. Jones 2014-03-07 16:13:23 UTC
Fixed upstream in:

6aa64ee3a3f1c990b5f9ce537f2b840273c3c1ba
d00840d727e4040a7958ecc613599d6ec2851e53
8c219636a272c4288f22392ff27b9c04580aecb4
7a0e71f7331540809db5f539d1a9fe2af050c56a
dff35285e491d1905d38c90d83fed98932cbc3b3

& regression test:

ebf8a3654ac4a691d48199adb8e92e182012a8c2
1ba2e3e14aa6d58bff26646a1328969fda44610f

Comment 5 Hu Zhang 2014-12-10 09:11:21 UTC
Verified the issue.

Host Version:
kernel-2.6.32-504.el6.x86_64

Packages Version:
libguestfs-1.20.11-12.el6.x86_64
libguestfs-java-1.20.11-12.el6.x86_64

verify steps:
1. javac -classpath /usr/share/java/libguestfs-1.20.11.jar InspectVM.java

2. java -classpath /usr/share/java/libguestfs-1.20.11.jar:. InspectVM RHEL7.1.64-hvm.raw
Root device: /dev/rhel/root
  Product name: Red Hat Enterprise Linux Server release 7.1 Beta (Maipo)
  Version:      7.1
  Type:         linux
  Distro:       rhel
  Number of apps installed = 497
    ModemManager-glib 1.1.0 6.git20130913.el7
    NetworkManager 0.9.11.0 7.git20141125.f32075d2.el7
    NetworkManager-config-server 0.9.11.0 7.git20141125.f32075d2.el7
    ...

No ArrayIndexOutOfBoundsException error returned.

Verified.

Comment 7 errata-xmlrpc 2015-07-22 05:55:13 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-1444.html