public inbox for java-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgcj/24583]  New: InetAddress.getLocalHost() returns broken InetAddress object when run in chroot
@ 2005-10-30  0:18 greenrd at gcc dot gnu dot org
  2005-10-30  0:21 ` [Bug libgcj/24583] " greenrd at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: greenrd at gcc dot gnu dot org @ 2005-10-30  0:18 UTC (permalink / raw)
  To: java-prs

When a Java program is run in a chroot environment on Linux,
InetAddress.getLocalHost() returns a broken InetAddress object (broken in the
same way as it was in bug 17069).

Test case:

import java.net.InetAddress;
import java.net.UnknownHostException;

public class TestAddr {

        public static void main (String args []) throws UnknownHostException {
                InetAddress.getLocalHost ().getAddress ();
        }

} // end of class TestAddr

The test case prints this inside the chroot:

Exception in thread "main" java.lang.NullPointerException
   at java.net.InetAddress.getAddress() (/usr/lib/libgcj.so.6.0.0)
   at TestAddr.main(java.lang.String[]) (Unknown Source)
   at gnu.java.lang.MainThread.call_main() (/usr/lib/libgcj.so.6.0.0)
   at gnu.java.lang.MainThread.run() (/usr/lib/libgcj.so.6.0.0)

and nothing when not in a chroot.

By using LD_LIBRARY_PATH I have verified that the brokenness _is_ triggered by
the chroot, not by the different versions of libc and libgcj that are
dynamically linked against when inside the chroot:

bash-3.00$ LD_LIBRARY_PATH=/mnt/rawhide/usr/lib:/mnt/rawhide/lib ldd
/mnt/rawhide/home/greenrd/testaddr
        linux-gate.so.1 =>  (0xffffe000)
        libgcc_s.so.1 => /mnt/rawhide/lib/libgcc_s.so.1 (0x00db1000)
        libgcj.so.6 => /mnt/rawhide/usr/lib/libgcj.so.6 (0x02000000)
        libm.so.6 => /mnt/rawhide/lib/libm.so.6 (0x00354000)
        libpthread.so.0 => /mnt/rawhide/lib/libpthread.so.0 (0x00390000)
        libz.so.1 => /mnt/rawhide/usr/lib/libz.so.1 (0x0037b000)
        libdl.so.2 => /mnt/rawhide/lib/libdl.so.2 (0x0034e000)
        libc.so.6 => /mnt/rawhide/lib/libc.so.6 (0xf7ed1000)
        /lib/ld-linux.so.2 (0x00248000)
bash-3.00$ LD_LIBRARY_PATH=/mnt/rawhide/usr/lib:/mnt/rawhide/lib
/mnt/rawhide/home/greenrd/testaddr
bash-3.00$

The real /dev, /proc and /sys are mounted inside the chroot, and /sbin/ifconfig
can see all the network interfaces and their IPs when run as the same user from
inside the chroot, so it is not the case that the kernel is hiding this
information.


-- 
           Summary: InetAddress.getLocalHost() returns broken InetAddress
                    object when run in chroot
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libgcj
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: greenrd at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24583


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libgcj/24583] InetAddress.getLocalHost() returns broken InetAddress object when run in chroot
  2005-10-30  0:18 [Bug libgcj/24583] New: InetAddress.getLocalHost() returns broken InetAddress object when run in chroot greenrd at gcc dot gnu dot org
@ 2005-10-30  0:21 ` greenrd at gcc dot gnu dot org
  2005-10-30 12:00 ` [Bug libgcj/24583] [4.0 only] InetAddress.getLocalHost() returns broken InetAddress object when local hostname cannot be resolved greenrd at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: greenrd at gcc dot gnu dot org @ 2005-10-30  0:21 UTC (permalink / raw)
  To: java-prs



------- Comment #1 from greenrd at gcc dot gnu dot org  2005-10-30 00:21 -------
Also, the hostname command does work inside the chroot - it returns the
hostname of the real machine. So I don't think this is a reoccurrence of bug
17069.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24583


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libgcj/24583] [4.0 only] InetAddress.getLocalHost() returns broken InetAddress object when local hostname cannot be resolved
  2005-10-30  0:18 [Bug libgcj/24583] New: InetAddress.getLocalHost() returns broken InetAddress object when run in chroot greenrd at gcc dot gnu dot org
  2005-10-30  0:21 ` [Bug libgcj/24583] " greenrd at gcc dot gnu dot org
@ 2005-10-30 12:00 ` greenrd at gcc dot gnu dot org
  2005-10-30 15:14 ` pinskia at gcc dot gnu dot org
  2006-01-29 17:46 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: greenrd at gcc dot gnu dot org @ 2005-10-30 12:00 UTC (permalink / raw)
  To: java-prs



------- Comment #2 from greenrd at gcc dot gnu dot org  2005-10-30 12:00 -------
The real problem here was that I had a typo in my /etc/hosts, so the hostname
could not be resolved. I've updated the bug summary.

GNU classpath 0.18 implements the correct behaviour:

$ jamvm TestAddr
java.net.UnknownHostException: lcoyle1
   at java.net.VMInetAddress.getHostByName (Native Method)
   at java.net.InetAddress.getAllByName (InetAddress.java:667)
   at java.net.InetAddress.getByName (InetAddress.java:622)
   at java.net.InetAddress.getLocalHost (InetAddress.java:777)
   at TestAddr.main (TestAddr.java:7)


-- 

greenrd at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|InetAddress.getLocalHost()  |[4.0 only]
                   |returns broken InetAddress  |InetAddress.getLocalHost()
                   |object when run in chroot   |returns broken InetAddress
                   |                            |object when local hostname
                   |                            |cannot be resolved


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24583


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libgcj/24583] [4.0 only] InetAddress.getLocalHost() returns broken InetAddress object when local hostname cannot be resolved
  2005-10-30  0:18 [Bug libgcj/24583] New: InetAddress.getLocalHost() returns broken InetAddress object when run in chroot greenrd at gcc dot gnu dot org
  2005-10-30  0:21 ` [Bug libgcj/24583] " greenrd at gcc dot gnu dot org
  2005-10-30 12:00 ` [Bug libgcj/24583] [4.0 only] InetAddress.getLocalHost() returns broken InetAddress object when local hostname cannot be resolved greenrd at gcc dot gnu dot org
@ 2005-10-30 15:14 ` pinskia at gcc dot gnu dot org
  2006-01-29 17:46 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-30 15:14 UTC (permalink / raw)
  To: java-prs



------- Comment #3 from pinskia at gcc dot gnu dot org  2005-10-30 15:14 -------
So this is fixed in 4.1.0?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24583


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libgcj/24583] [4.0 only] InetAddress.getLocalHost() returns broken InetAddress object when local hostname cannot be resolved
  2005-10-30  0:18 [Bug libgcj/24583] New: InetAddress.getLocalHost() returns broken InetAddress object when run in chroot greenrd at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2005-10-30 15:14 ` pinskia at gcc dot gnu dot org
@ 2006-01-29 17:46 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-29 17:46 UTC (permalink / raw)
  To: java-prs



------- Comment #4 from pinskia at gcc dot gnu dot org  2006-01-29 17:46 -------
Fixed in 4.1.0.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.1.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24583


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-01-29 17:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-30  0:18 [Bug libgcj/24583] New: InetAddress.getLocalHost() returns broken InetAddress object when run in chroot greenrd at gcc dot gnu dot org
2005-10-30  0:21 ` [Bug libgcj/24583] " greenrd at gcc dot gnu dot org
2005-10-30 12:00 ` [Bug libgcj/24583] [4.0 only] InetAddress.getLocalHost() returns broken InetAddress object when local hostname cannot be resolved greenrd at gcc dot gnu dot org
2005-10-30 15:14 ` pinskia at gcc dot gnu dot org
2006-01-29 17:46 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).