Skip to main content

Name resolution configuration in CVM

30 replies [Last post]
ken_gilmer
Offline
Joined: 2007-01-19

Hello :)

I'm having a problem resolving hostnames into ip addresses. On the command line I have no problem resolving IP addresses. However when I do a Inet4Address.getByName("myhost") an unknown host exception is generated. With some googling I've found references to set the IP address of the name server of the 1.4 JVM. Are there equivalent properties for the CVM? Am I missing something?

TIA
ken

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
angelr
Offline
Joined: 2008-03-14

Chris,

I tried the latest from svn. Same result:

CVM_JIT=false USE_AAPCS=false
root@BUG / # CDC-phoneme_advanced_mr2_b65-linux_arm_generic-bin-rev10830/bin/cvm HostQuery
user.language en
user.region US
java.net.UnknownHostException: yahoo.com: yahoo.com
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at java.net.InetAddress.getByName(Unknown Source)
at HostQuery.main(Unknown Source)
at sun.misc.CVM.runMain(Unknown Source)

root@BUG / # CDC-phoneme_advanced_mr2_b65-linux_arm_generic-bin-rev10830/bin/cvm -version
Product: phoneME Advanced (phoneme_advanced_mr2-b65)
Profile: CDC Specification 1.1
JVM: CVM phoneme_advanced_mr2-b65 (interpreter loop)

CVM_JIT=false USE_AAPCS=true
root@BUG / # CDC-phoneme_advanced_mr2_b65-linux_arm_generic-bin-rev10830/bin/cvm HostQuery
user.language en
user.region US
getAddress =yahoo.com/66.94.234.13
root@BUG / # CDC-phoneme_advanced_mr2_b65-linux_arm_generic-bin-rev10830/bin/cvm -version
Product: phoneME Advanced (phoneme_advanced_mr2-b65)
Profile: CDC Specification 1.1
JVM: CVM phoneme_advanced_mr2-b65 (interpreter loop)
root@BUG / #

-Angel

cjplummer
Offline
Joined: 2006-10-16

The JIT may be causing a memory corruption, which is why you are seeing the mangled name in the DNS lookup. Not that it will really prove anything, but try building with CVM_JIT=true and run with -Xjit:compile=none.

Make sure you are building with CVM_DEBUG=true until this problem is resolved.

What version of the source are you using? Is it MR1 or the latest version of MR2 on the phoneme trunk?

Chris

cjplummer
Offline
Joined: 2006-10-16

If you got the AAPCS assert with the JIT, then you always need to build with USE_AAPCS=true, even without the JIT. The assert went into some JIT related code because it was a convenient place to make the AAPCS check. I believe it was done in JIT code because we didn't have any cpu specific hooks when just doing an interpreter port. However, the interpreter also has AAPCS dependencies. Specifically, CVMjniInvokeNative needs to know if AAPCS is being used or not.

Chris

Message was edited by: cjplummer

Hinkmond Wong

phonemeadvanced@mobileandembedded.org wrote:
> If you got the AAPCS assert with the JIT, then you always need to build with USE_AAPCS=true, even without the JIT. The assert when into some JIT related code because it was a convenient place to make the AAPCS check. I believe it was done in JIT code because we didn't have any cpu specific hooks when just doing an interpreter port. However, the interpreter also has AAPCS dependencies. Specifically, CVMjniInvokeNative needs to know if AAPCS is being used or not.
>

Hi Angel,

Did you find out the root cause of why adding USE_AAPCS=true allows the
DNS name resolution to work in CVM? It seems strange that one affects
the other, unless it is a memory corruption problem as Chris suggested.
Was that the ultimate cause when you didn't have USE_AAPCS=true?

Thanks,
Hinkmond

---------------------------------------------------------------------
To unsubscribe, e-mail: advanced-unsubscribe@phoneme.dev.java.net
For additional commands, e-mail: advanced-help@phoneme.dev.java.net

angelr
Offline
Joined: 2008-03-14

I have not determined the root cause. However, the strace with USE_AAPCS=true no longer shows the library name as being corrupted. I'm leaning towards a memory corruption issue like Chris suggested.

The fact that my compiler is gcc 4.1.1 compiler leads me to believe that gcc is generating something that the JVM isn't expecting unless I explicitly tell it via USE_AAPCS=true. With gcc 3.4.4, I do not need to set USE_AAPCS, it always works (on another device).

Here are my compiler configurations:

angel@MDEX61Linux:~/$ /scratchbox/compilers/cs2005q3.2-glibc2.5-arm/bin/arm-linux-gcc -v
Reading specs from /scratchbox/compilers/cs2005q3.2-glibc2.5-arm/bin/../lib/gcc/arm-none-linux-gnueabi/3.4.4/specs
Configured with: /home/kl/cs2005q3-2_toolchain/gcc/glibc/work/gcc-2005q3-2/configure --build=i386-linux --host=i386-linux --target=arm-none-linux-gnueabi --prefix=/scratchbox/compilers/cs2005q3.2-glibc-arm --with-headers=/scratchbox/compilers/cs2005q3.2-glibc-arm/usr/include --enable-languages=c,c++ --enable-shared --enable-threads --disable-checking --enable-symvers=gnu --program-prefix=arm-linux- --with-gnu-ld --enable-__cxa_atexit --disable-libssp --disable-libstdcxx-pch --with-cpu= --enable-interwork
Thread model: posix
gcc version 3.4.4 (release) (CodeSourcery ARM 2005q3-2)

angel@MDEX61Linux:~/$ arm-none-linux-gnueabi-gcc -v
Using built-in specs.
Target: arm-none-linux-gnueabi
Configured with: /usr/src/redhat/BUILD/crosstool/source/gcc-4.1.1/configure --target=arm-none-linux-gnueabi --host=i686-host_pc-linux-gnu --prefix=/opt/freescale/usr/local/gcc-4.1.1-glibc-2.4-nptl-6/arm-none-linux-gnueabi --disable-libunwind-exceptions --with-headers=/opt/freescale/usr/local/gcc-4.1.1-glibc-2.4-nptl-6/arm-none-linux-gnueabi/arm-none-linux-gnueabi/include --with-local-prefix=/opt/freescale/usr/local/gcc-4.1.1-glibc-2.4-nptl-6/arm-none-linux-gnueabi/arm-none-linux-gnueabi --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long
Thread model: posix
gcc version 4.1.1

Maybe some JVM guru (Hinkmond or Chris?) can shed some light into the meaning of -DAAPCS. In the meantime I should look at what -DAAPCS triggers on the CVM source code and what exactly is AAPCS in the ARM specification.

I'm happy that the symptom is fixed however I'ld like to know if one of the PhoneME contributors would look at this problem and say: "Ofcourse, you must use USE_AAPCS=true." Although, Chris already mentioned that I should always build with AAPCS since the runtime assertion suggested it when compiling with CVM_JIT=true.

Regards,
Angel

cjplummer
Offline
Joined: 2006-10-16

I'm not sure of everything that is different between APCS and AAPCS, but the main ones CVM cares about are the 64-bit stack frame alignment requirement and the 64-bit alignment of 64-bit arguments.

For the stack frame alignment, we just always do it now, even for APCS which doesn't require it. It does not hurt to 64-bit align the stack frame, even when not required. However, for the alignment of 64-bit arguments, you can only do this for AAPCS. It will break APCS code, so the CVMjniInvokeNative code needs to know whether or not it should be aligning 64-bit arguments. If it does it wrong, you will get a garbage for the first unaligned 64-bit argument, and all arguments after it. This can result in pretty much any type of crash or corruption.

One other requirement of AAPCS is that all 64-bit accesses to 64-bit values must be aligned. This affects the interpreter, which will attempt 64-bit loads of 64-bit java locals and fields if unaligned 64-bit loads are allowed. Since AAPCS doesn't allow for these unaligned loads, we need to load the 64-bit value 32-bits at a time. Thus in doubleword_arch.h you will see:

/* AAPCS calling conventions don't allow unaligned 64-bit access. */
#ifdef AAPCS
#undef CAN_DO_UNALIGNED_DOUBLE_ACCESS
#undef CAN_DO_UNALIGNED_INT64_ACCESS
#else
#define CAN_DO_UNALIGNED_DOUBLE_ACCESS
#define CAN_DO_UNALIGNED_INT64_ACCESS
#endif

Getting this wrong rmay result in a bus error, although I think this is unlikely on existing ARM processors.

Chris

Chris

angelr
Offline
Joined: 2008-03-14

BTW, here's what you requested a few posts ago.

CVM Configuration:
Java stack chunk size (stackChunkSize): 1024
Java stack minimum size (stackMinSize): 1024
Java stack maximum size (stackMaxSize): 131072
GC[SS]: Initialized semi-space gen for generational GC
Size of *each* semispace in bytes=1048576
Limits of generation = [0x4016e000,0x4036e000)
First semispace = [0x4016e000,0x4026e000)
Second semispace = [0x4026e000,0x4036e000)
GC[MC]: Initialized mark-compact gen for generational GC
Size of the space in bytes=1048576
Limits of generation = [0x4036e000,0x4046e000)
GC[generational]: Sizes
youngGen = min 1048576 start 1048576 max 1048576
oldGen = min 1048576 start 1048576 max 4194304
overall = min 2097152 start 2097152 max 5242880
GC[generational]: Auxiliary data structures
heapBaseMemoryArea=[0x4016e000,0x4076e200)
cardTable=[0x4076e000,0x40771000)
objectHeaderTable=[0x40771000,0x40774000)
summaryTable=[0x40774000,0x40780000)
user.language en
user.region US
Host: yahoo.com
Locale: C
java.net.UnknownHostException: yahoo.com: yahoo.com
at java.net.InetAddress.getAllByName0(Ljava/lang/String;Z)[Ljava/net/InetAddress;(InetAddress.java:1046)
at java.net.InetAddress.getAllByName0(Ljava/lang/String;)[Ljava/net/InetAddress;(InetAddress.java:1016)
at java.net.InetAddress.getAllByName(Ljava/lang/String;)[Ljava/net/InetAddress;(InetAddress.java:1010)
at java.net.InetAddress.getByName(Ljava/lang/String;)Ljava/net/InetAddress;(InetAddress.java:924)
at HostQuery.main([Ljava/lang/String;)V(HostQuery.java:12)
at sun.misc.CVM.runMain()V(CVM.java:514)

Hinkmond Wong

phonemeadvanced@mobileandembedded.org wrote:
> BTW, here's what you requested a few posts ago.
>
> CVM Configuration:
> Java stack chunk size (stackChunkSize): 1024
> Java stack minimum size (stackMinSize): 1024
> Java stack maximum size (stackMaxSize): 131072
> GC[SS]: Initialized semi-space gen for generational GC
> Size of *each* semispace in bytes=1048576
> Limits of generation = [0x4016e000,0x4036e000)
> First semispace = [0x4016e000,0x4026e000)
> Second semispace = [0x4026e000,0x4036e000)
> GC[MC]: Initialized mark-compact gen for generational GC
> Size of the space in bytes=1048576
> Limits of generation = [0x4036e000,0x4046e000)
> GC[generational]: Sizes
> youngGen = min 1048576 start 1048576 max 1048576
> oldGen = min 1048576 start 1048576 max 4194304
> overall = min 2097152 start 2097152 max 5242880
> GC[generational]: Auxiliary data structures
> heapBaseMemoryArea=[0x4016e000,0x4076e200)
> cardTable=[0x4076e000,0x40771000)
> objectHeaderTable=[0x40771000,0x40774000)
> summaryTable=[0x40774000,0x40780000)
> user.language en
> user.region US
> Host: yahoo.com
> Locale: C
> java.net.UnknownHostException: yahoo.com: yahoo.com
> at java.net.InetAddress.getAllByName0(Ljava/lang/String;Z)[Ljava/net/InetAddress;(InetAddress.java:1046)
> at java.net.InetAddress.getAllByName0(Ljava/lang/String;)[Ljava/net/InetAddress;(InetAddress.java:1016)
> at java.net.InetAddress.getAllByName(Ljava/lang/String;)[Ljava/net/InetAddress;(InetAddress.java:1010)
> at java.net.InetAddress.getByName(Ljava/lang/String;)Ljava/net/InetAddress;(InetAddress.java:924)
> at HostQuery.main([Ljava/lang/String;)V(HostQuery.java:12)
> at sun.misc.CVM.runMain()V(CVM.java:514)
>
>

Hi Angel,

Do you know if IPv6 is supported on your device or not?

Specifically, can you put some debug lines in InetAdress.java and rebuild:

src/share/classes/java/net/InetAddress.java
===

/*
* Simple factory to create the impl
*/
class InetAddressImplFactory {

static InetAddressImpl create() {
Object o;
if (isIPv6Supported()) {
o = InetAddress.loadImpl("Inet6AddressImpl");
// Insert this:
System.out.println("*** Inet6AddressImpl created...");
} else {
o = InetAddress.loadImpl("Inet4AddressImpl");
// And, insert this:
System.out.println("*** Inet4AddressImpl created...");
}
return (InetAddressImpl)o;
}

private static native boolean isIPv6Supported();
}

Can you add the above println() statements in, rebuild, rerun, and tell
me if it says it created the Inet6 or Inet4 impl?

It's this line that really bugs me:

byte_array = nameService.lookupAllHostAddr(host);

which goes to here:

nameService = new NameService() {
public byte[][] lookupAllHostAddr(String host)
throws UnknownHostException {
return impl.lookupAllHostAddr(host);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}

But, that line (line # 734) does not show up on your stack trace. You
might have to throw in the println() there to see if you are getting the
UHE in NameService or not. I think you are, which will lead us to more
investigation...

Thanks,
Hinkmond

---------------------------------------------------------------------
To unsubscribe, e-mail: advanced-unsubscribe@phoneme.dev.java.net
For additional commands, e-mail: advanced-help@phoneme.dev.java.net

angelr
Offline
Joined: 2008-03-14

Hi Hinkmod,

CVM_JIT=true allows dns to work.
CVM_JIT=false causes it to break.

I'm using the default GNUMakefile under arm-linux-generic.

My gcc -v is:

Using built-in specs.
Target: arm-none-linux-gnueabi
Configured with: /usr/src/redhat/BUILD/crosstool/source/gcc-4.1.1/configure --target=arm-none-linux-gnueabi --host=i686-host_pc-linux-gnu --prefix=/opt/freescale/usr/local/gcc-4.1.1-glibc-2.4-nptl-6/arm-none-linux-gnueabi --disable-libunwind-exceptions --with-headers=/opt/freescale/usr/local/gcc-4.1.1-glibc-2.4-nptl-6/arm-none-linux-gnueabi/arm-none-linux-gnueabi/include --with-local-prefix=/opt/freescale/usr/local/gcc-4.1.1-glibc-2.4-nptl-6/arm-none-linux-gnueabi/arm-none-linux-gnueabi --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long
Thread model: posix
gcc version 4.1.1

Regards,
Angel

Hinkmond Wong

phonemeadvanced@mobileandembedded.org wrote:
> Hi Hinkmod,
>
> CVM_JIT=true allows dns to work.
> CVM_JIT=false causes it to break.
>
> I'm using the default GNUMakefile under arm-linux-generic.
>

That's an interesting clue. Do you know if you cross-compiler provides
any static libs (lib*.a) in the cross-compiler library area:

/opt/freescale/usr/local/gcc-4.1.1-glibc-2.4-nptl-6/arm-none-linux-gnueabi/lib

that may have not have the corresponding lib*.so dynamic lib found on your target device?

Maybe, the CVM_JIT=true is statically linking all the Linux static libs in correctly (that's why it works), but the CvM_JIT=false dynamic linking build is somehow missing a lib*.so on your target device, or more likely a lib*.so on your target device may be out of sync with the lib*.so found in your cross-compiler lib dir on your host system:

/opt/freescale/usr/local/gcc-4.1.1-glibc-2.4-nptl-6/arm-none-linux-gnueabi/lib

Is there any chance those some of the libs are out of sync on your target device vs. your host system cross-compiler?

Hinkmond

---------------------------------------------------------------------
To unsubscribe, e-mail: advanced-unsubscribe@phoneme.dev.java.net
For additional commands, e-mail: advanced-help@phoneme.dev.java.net

billp
Offline
Joined: 2006-09-19

Maybe I missed it, but what is the platform CVM is running on? What is the underlying network interface (BSD sockets?, Winsock?). Assuming this is IPv4 then the actual native code doing the lookup is in src//native/java/net/Inet4AddressImpl_md.c. This has to be ported to your particular network subsystem. If you can run gdb or some other debugger on this to debug CVM you could put a breakpoint in the
Java_java_net_Inet4AddressImpl_lookupAllHostAddr() function in the above named file to see why it is throwing the exception. Well, it's throwing the exception because it apparently got NULL back when it called the underlying OS gethostbyname API. If this is not plain vanilla linux or win32 then you may have to tweak these native files for your platform network API.

bill

angelr
Offline
Joined: 2008-03-14

Hi Bill,

Thanks for the pointer; gethostbyname_r is returning null.

I dove into Inet4AddressImpl_md.c file and saw that cvm uses the gethostbyname_r native call. Therefore, I created a simple c program which prints out the host entry structure returned by gethostbyname_r and it works flawlessly.

Furthermore, I straced my native program and cvm HostQuery and witnessed the following.

My native program loads libnss_dns (as configured in nsswitch.conf):
open("/lib/libnss_dns.so.2", O_RDONLY) = 3
which results in loading libresolv.so and the dns query.

On the other hand cvm HostQuery fails to load libnss_dns.so due to, what appears to be, name mangling:
open("/lib/ð@ss_dns.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
Failure to load this causes the dns lookup to not continue.

At first I thought this might have something to do with cvm setting the locale, however, I added a print out right before gethostbyname_r and the locale is set to "C".

Any ideas why the library name gets mangled? Could it be due to some java.security setting?

I verified that HostQuery.java works in an X86 and no name mangling occurs; The issue seems with my ARM build.

I appended the following flags to the arm-linux-generic GNUMake file:

CC_ARCH_FLAGS = -B$(ROOTFS)/lib
CC_ARCH_FLAGS += -B$(ROOTFS)/usr/lib//
CC_ARCH_FLAGS += -iwithprefix include
CC_ARCH_FLAGS += -O2
CC_ARCH_FLAGS += -fsigned-char
CC_ARCH_FLAGS += -mabi=aapcs-linux
CC_ARCH_FLAGS += -mfpu=vfp
CC_ARCH_FLAGS += -mfloat-abi=softfp

and turned JIT off.

Regards,
Angel

Hinkmond Wong

phonemeadvanced@mobileandembedded.org wrote:
> Hi Bill,
>
> Thanks for the pointer; gethostbyname_r is returning null.
>
> I dove into Inet4AddressImpl_md.c file and saw that cvm uses the gethostbyname_r native call. Therefore, I created a simple c program which prints out the host entry structure returned by gethostbyname_r and it works flawlessly.
>
> Furthermore, I straced my native program and cvm HostQuery and witnessed the following.
>
> My native program loads libnss_dns (as configured in nsswitch.conf):
> open("/lib/libnss_dns.so.2", O_RDONLY) = 3
> which results in loading libresolv.so and the dns query.
>
> On the other hand cvm HostQuery fails to load libnss_dns.so due to, what appears to be, name mangling:
> open("/lib/ð@ss_dns.so.2", O_RDONLY) = -1 ENOENT (No such file or directory

Hi Angel,

Can you try running "ldd" on your specific cvm binary and/or your CDC
lib*.so files? Does one of them try pulling in /lib/libnss_dns.so.2 and
fail?

I think that dependency is not being pulled in from CDC or cvm but from
one of the Linux lib*.so files. If you try hunting around using "ldd"
you should be able to figure out which file (either cvm, lib*.so from
CDC, or lib*.so from Linux) is pulling in /lib/libnss_dns.so.2.

Or, does your strace output indicate who is trying to do the call:

open("/lib/ð@ss_dns.so.2", O_RDONLY) = -1 ENOENT (No such file or directory

Thanks,
Hinkmond

---------------------------------------------------------------------
To unsubscribe, e-mail: advanced-unsubscribe@phoneme.dev.java.net
For additional commands, e-mail: advanced-help@phoneme.dev.java.net

angelr
Offline
Joined: 2008-03-14

It's part of glibc's nss (name service switch) implementation. Depending on what is specified in nsswitch.conf it will perform a dlopen and use it. So cvm depends on libc which depends on libnss_dns.so if it's set via nsswitch.conf.

What is interesting is the fact that it works with a simple c program, but the open call for libnss_dns(the mangled one) results in ENOENT. I double checked my compiler settings and paths. I even cut and paste the gcc command line from the cvm build when building Inet4Address_md.c and used it to build my native app. Same result: native app works, cvm doesn't...

-Angel

Hinkmond Wong

phonemeadvanced@mobileandembedded.org wrote:
> It's part of glibc's nss (name service switch) implementation. Depending on what is specified in nsswitch.conf it will perform a dlopen and use it. So cvm depends on libc which depends on libnss_dns.so if it's set via nsswitch.conf.
>
> What is interesting is the fact that it works with a simple c program, but the open call for libnss_dns(the mangled one) results in ENOENT. I double checked my compiler settings and paths. I even cut and paste the gcc command line from the cvm build when building Inet4Address_md.c and used it to build my native app. Same result: native app works, cvm doesn't...
>

Hi Angel,

On your target device, what is the $LANG setting?

If it's not already, please try setting it to:

export LANG=en_US.UTF-8

and run the cvm command again.

Was it being set to "C" for both your native test app and when you run
with cvm? Does it change if you set LANG to en_US or en_US.UTF-8?

Thanks,

Hinkmond

---------------------------------------------------------------------
To unsubscribe, e-mail: advanced-unsubscribe@phoneme.dev.java.net
For additional commands, e-mail: advanced-help@phoneme.dev.java.net

angelr
Offline
Joined: 2008-03-14

Both CVM and native app (printf("Locale: %s\n", setlocale(LC_ALL, NULL)) ) say it is "C" regardless of export LANG=en_US.UTF-8 right before the call to gethostbyname_r.

-Angel

cjplummer
Offline
Joined: 2006-10-16

> Oh, and cvm -version:
>
> root@BUG /tmp # /opt/phoneme_adv-revUNKNOWN/bin/cvm
> -version
> Product: phoneME Advanced (phoneme_advanced_mr2-b32)
> Profile: Personal Profile Specification 1.1
> JVM: CVM phoneme_advanced_mr2-b32 (interpreter
> loop)

I see now you are using a rather old version of MR2. Try using the latest version on the trunk. There has been at least one ARM ABI related fix that I know of since b32.

Chris

angelr
Offline
Joined: 2008-03-14

cjplummer,

Just tried the latest tar ball. The problem still persists.

linux_arm_generic-bin-revUNKNOWN/bin/cvm HostQuery
user.language en
user.region US
java.net.UnknownHostException: yahoo.com: yahoo.com
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at java.net.InetAddress.getByName(Unknown Source)
at HostQuery.main(Unknown Source)
at sun.misc.CVM.runMain(Unknown Source)

linux_arm_generic-bin-revUNKNOWN/bin/cvm -version
Product: phoneME Advanced (phoneme_advanced_mr2-b34)
Profile: CDC Specification 1.1
JVM: CVM phoneme_advanced_mr2-b34 (interpreter loop)

-Angel

cjplummer
Offline
Joined: 2006-10-16

b34 is still very old. You need to use svn to checkout the latest source from the trunk.

Also, Dean pointed out to me that you said it works with the JIT, not without the JIT, so I had it backwards. I'm still guessing there is a memory corruption, and enabling the JIT just changed the memory layout so now different memory is corrupted and you are not noticing it.

Chris

angelr
Offline
Joined: 2008-03-14

Thanks Chris. I'll from an svn checkout.

To clarify:

USE_AAPCS=true is what makes it work,

CVM_JIT=true or CVM_JIT=false do not make a difference.

Initially I thought CVM_JIT=true is what made it work. However, CVM_JIT=true just forced me to compile with -DAAPCS. USE_AAPCS is the only flag that causes it fail or not.

Also, please note that my toolchain is gcc 4.1.1 with gnueabi as posted in the previous thread. I read somewhere that as of gcc 4.1 (not exactly sure of the version) the default ABI changed.

-Angel

ken_gilmer
Offline
Joined: 2007-01-19

Hi Hinkmond,

Here is the information you requested~

Compiling your class:

kgilmer@bugplus:/tmp$ javac -target 1.4 -source 1.4 HostQuery.java

Running on CVM on target machine:

root@BUG /tmp # /opt/phoneme_adv-revUNKNOWN/bin/cvm HostQuery
java.net.UnknownHostException: yahoo.com: yahoo.com
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at java.net.InetAddress.getByName(Unknown Source)
at HostQuery.main(Unknown Source)
at sun.misc.CVM.runMain(Unknown Source)
root@BUG /tmp # ping yahoo.com
Using fallback suid method
PING yahoo.com (66.94.234.13): 56 data bytes

--- yahoo.com ping statistics ---
8 packets transmitted, 0 packets received, 100% packet loss

////////////////////////////////////////////

I was unable to ping anything, I'm assuming it's due to the wifi network I'm currently connected to. However it did resolve the name. I'm able to confirm networking is working with wget:

root@BUG /tmp # wget yahoo.com
--00:15:20-- http://yahoo.com/
=> `index.html'
Resolving yahoo.com... 216.109.112.135, 66.94.234.13
Connecting to yahoo.com[216.109.112.135]:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://www.yahoo.com/ [following]
--00:15:21-- http://www.yahoo.com/
=> `index.html'
Resolving www.yahoo.com... 209.131.36.158
Connecting to www.yahoo.com[209.131.36.158]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9,533 [text/html]

100%[====================================>] 9,533 --.--K/s

00:15:21 (271.52 KB/s) - `index.html' saved [9533/9533]

//////////////////////////////////

The target /etc/resolv.conf is set to:

nameserver 4.2.2.2

Hope that helps.

thx
ken

ken_gilmer
Offline
Joined: 2007-01-19

Oh, and cvm -version:

root@BUG /tmp # /opt/phoneme_adv-revUNKNOWN/bin/cvm -version
Product: phoneME Advanced (phoneme_advanced_mr2-b32)
Profile: Personal Profile Specification 1.1
JVM: CVM phoneme_advanced_mr2-b32 (interpreter loop)

Hinkmond Wong

phonemeadvanced@mobileandembedded.org wrote:
> Oh, and cvm -version:
>
> root@BUG /tmp # /opt/phoneme_adv-revUNKNOWN/bin/cvm -version
> Product: phoneME Advanced (phoneme_advanced_mr2-b32)
> Profile: Personal Profile Specification 1.1
> JVM: CVM phoneme_advanced_mr2-b32 (interpreter loop)
>
> root@BUG /tmp # /opt/phoneme_adv-revUNKNOWN/bin/cvm HostQuery
> java.net.UnknownHostException: yahoo.com: yahoo.com
> at java.net.InetAddress.getAllByName0(Unknown Source)
> at java.net.InetAddress.getAllByName0(Unknown Source)
> at java.net.InetAddress.getAllByName(Unknown Source)
> at java.net.InetAddress.getByName(Unknown Source)
> at HostQuery.main(Unknown Source)
> at sun.misc.CVM.runMain(Unknown Source)
> root@BUG /tmp # ping yahoo.com
> Using fallback suid method
> PING yahoo.com (66.94.234.13): 56 data bytes
>
> --- yahoo.com ping statistics ---
> 8 packets transmitted, 0 packets received, 100% packet loss

Hi Ken,

Can you run with a debug CVM? This way we can get the line number in
java.net.InetAddress within the getAllByName0() method where it's
throwing the UnknowHostException().

I'm having suspicions that the CVM is having the same problem as why
your ping does not work.

Can you try taking your WiFi access point out of the picture to get ping
to work, and after it works then try the HostQuery app with CVM again?

Is there some type of firewall on your WiFi access point you can turn
off to get ping to work?

Also, can you try using nslookup on your system and copy & paste the
results?

Ex.
nslookup yahoo.com
Server: 129.145.155.220
Address: 129.145.155.220#53

Non-authoritative answer:
Name: yahoo.com
Address: 66.94.234.13
Name: yahoo.com
Address: 216.109.112.135

I'm thinking your nslookup is not working either (for external host
names), probably because of your WiFi. So, getting both ping and
nslookup to work, will probably get CVM to work also.

Hinkmond

---------------------------------------------------------------------
To unsubscribe, e-mail: advanced-unsubscribe@phoneme.dev.java.net
For additional commands, e-mail: advanced-help@phoneme.dev.java.net

angelr
Offline
Joined: 2008-03-14

Hi Hinkmod,

Those are good suggestions. Unfortunately, at the moment we do not have nslookup on the target device (I'm working on crosscompiling it). I do, however, have another piece of important information.

I hooked up wireshark (networking monitoring tool) and saw that "ping yahoo.com" provokes the target device to emit a DNS packet:

0000 26 1d 5f 0c 65 c0 5e 7e 01 56 69 be 08 00 45 00 &._.e.^~ .Vi...E.
0010 00 37 60 ab 40 00 40 11 bf f3 0a 0a 0a 0a 04 02 .7`.@.@. ........
0020 02 02 08 04 00 35 00 23 aa 9f e6 95 01 00 00 01 .....5.# ........
0030 00 00 00 00 00 00 05 79 61 68 6f 6f 03 63 6f 6d .......y ahoo.com
0040 00 00 01 00 01 .....

where as "cvm HostQuery" does not.

Due to this information I believe we can safely assume it's not a networking issue outside of the target device (or wifi access point). In addition, since ping does emit the DNS packet, the difference is in how the JVM is handling the dns lookup vs ping if at all.

Regards,
Angel

Hinkmond Wong

phonemeadvanced@mobileandembedded.org wrote:
> where as "cvm HostQuery" does not.
>
> Due to this information I believe we can safely assume it's not a networking issue outside of the target device (or wifi access point). In addition, since ping does emit the DNS packet, the difference is in how the JVM is handling the dns lookup vs ping if at all.
>

Hi Angel,

That's good info to know. Can you run a debug cvm with HostQuery to get
the source code line numbers in the stack trace?

Hinkmond

---------------------------------------------------------------------
To unsubscribe, e-mail: advanced-unsubscribe@phoneme.dev.java.net
For additional commands, e-mail: advanced-help@phoneme.dev.java.net

Hinkmond Wong

phonemeadvanced@mobileandembedded.org wrote:
> Hello :)
>
> I'm having a problem resolving hostnames into ip addresses. On the command line I have no problem resolving IP addresses. However when I do a Inet4Address.getByName("myhost") an unknown host exception is generated. With some googling I've found references to set the IP address of the name server of the 1.4 JVM. Are there equivalent properties for the CVM? Am I missing something?
>

Hi Ken,

Are you trying to resolve a hostname external to your network (outside
your firewall)? I'm guessing if you use a hostname that is inside your
local firewall, it probably works but outside is not working. Is that
correct?

If so, then I think you are on the right track that you might need to
set your http.proxyHost and http.proxyPort Java system properties (for
CDC just like Java SE 1.4.2), if you have a Web proxy set on your
network in order to get to external hosts.

Ex.

cvm -Dhttp.proxyHost=192.168.254.254 -Dhttp.proxyPort=9000 ...

Does that make any difference?

Hinkmond

---------------------------------------------------------------------
To unsubscribe, e-mail: advanced-unsubscribe@phoneme.dev.java.net
For additional commands, e-mail: advanced-help@phoneme.dev.java.net

ken_gilmer
Offline
Joined: 2007-01-19

Hi Hinkmond,

Thanks for your quick response. Well, I think our problem is at a lower level than HTTP proxy, if I understand correctly. For example, I can add a host entry into /etc/hosts:

192.168.0.10 myhost

I can then ping that from the shell. However when I create a java program that calls Inet4Address.getByName("myhost"), I get a hostname resolution error. Similarly, but without any host entry, I can for example ping yahoo.com from the shell but I cannot resolve yahoo.com from the CVM. It seems that the cvm is trying to resolve hosts in a different way than the Linux system itself...

Hinkmond Wong

phonemeadvanced@mobileandembedded.org wrote:
> Hi Hinkmond,
>
> Thanks for your quick response. Well, I think our problem is at a lower level than HTTP proxy, if I understand correctly. For example, I can add a host entry into /etc/hosts:
>
> 192.168.0.10 myhost
>
> I can then ping that from the shell. However when I create a java program that calls Inet4Address.getByName("myhost"), I get a hostname resolution error. Similarly, but without any host entry, I can for example ping yahoo.com from the shell but I cannot resolve yahoo.com from the CVM. It seems that the cvm is trying to resolve hosts in a different way than the Linux system itself...
> [Message sent by forum member 'ken_gilmer' (ken_gilmer)]
>

Have you tried the other way (from top down) to get the IP address
(first instantiating the class)?

Ex.
InetSocketAddress inet = new InetSocketAddress("hostname", port);
System.out.println(inet.getAddress().toString());

I think there might be a bug you have found when trying to use a static
method to resolve the hostname without first creating a new instance of
a InetAddress/Inet*Address class.

If you can get to it that way instead, I think you still might have
found a bug.

Hinkmond

---------------------------------------------------------------------
To unsubscribe, e-mail: advanced-unsubscribe@phoneme.dev.java.net
For additional commands, e-mail: advanced-help@phoneme.dev.java.net

angelr
Offline
Joined: 2008-03-14

Hi Hinkmond,

Thanks for your suggestion. However, inet.getAddress() returns null for me. Perhaps you can help me with the following:

I dove into the the VM code and found :
////////////////////////////////////////////////////////////////////////////////
InetAddress.java
////////////////////////////////////////////////////////////////////////////////
static {
// create the impl
impl = (new InetAddressImplFactory()).create();

// get name service if provided and requested
String provider = null;;
String propPrefix = "sun.net.spi.nameservice.provider.";
int n = 1;
while (nameService == null) {
provider
= (String)AccessController.doPrivileged(
new GetPropertyAction(propPrefix+n, "default"));
n++;
if (provider.equals("default")) {
// initialize the default name service
nameService = new NameService() {
public byte[][] lookupAllHostAddr(String host)
throws UnknownHostException {
return impl.lookupAllHostAddr(host);
}
public String getHostByAddr(byte[] addr)
throws UnknownHostException {
return impl.getHostByAddr(addr);
}
};
break;
}

final String providerName = provider;

try {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedExceptionAction() {
public Object run() {
Iterator itr
= Service.providers(NameServiceDescriptor.class);
while (itr.hasNext()) {
NameServiceDescriptor nsd
= (NameServiceDescriptor)itr.next();
if (providerName.
equalsIgnoreCase(nsd.getType()+","
+nsd.getProviderName())) {
try {
nameService = nsd.createNameService();
break;
} catch (Exception e) {
e.printStackTrace();
System.err.println(
"Cannot create name service:"
+providerName+": " + e);
}
}
} /* while */
return null;
}
});
} catch (java.security.PrivilegedActionException e) {
}

}
}
////////////////////////////////////////////////////////////////////////////////

which looks for sun.net.spi.nameservice.provider.1 to be set. If it's not set it uses "default."
I believe the UnknownHostException is being thrown from whichever nameservice provider is set. Is the default nameservice provider sufficient for what we are trying to achieve?

I tried:
-Dsun.net.spi.nameservice.provider.1="dns"
-Dsun.net.spi.nameservice.provider.1="sun"
-Dsun.net.spi.nameservice.provider.1="dns,sun"

without any luck.

Regards,
Angel

Hinkmond Wong

phonemeadvanced@mobileandembedded.org wrote:
> Hi Hinkmond,
>
> Thanks for your suggestion. However, inet.getAddress() returns null for me. Perhaps you can help me with the following:
>
> I dove into the the VM code and found :
>
...
> I believe the UnknownHostException is being thrown from whichever nameservice provider is set. Is the default nameservice provider sufficient for what we are trying to achieve?
>
> I tried:
> -Dsun.net.spi.nameservice.provider.1="dns"
> -Dsun.net.spi.nameservice.provider.1="sun"
> -Dsun.net.spi.nameservice.provider.1="dns,sun"
>
> without any luck.
>

Hi Angel,

You shouldn't need to set any of those sun.net.spi.* properties. Those
properties are set to do the right thing on a Linux system. I think it
might be a problem with your Linux environment or an issue with
compiling your Java app you are trying to run. You may not be compiling
with the "javac -target 1.4 -source 1.4" flags?

Can you compile and run the following Java app using your environment?

HostQuery.java
---

import java.net.InetAddress;

public class HostQuery {
public static void main( String paramList[] ){
try {
System.err.println("getAddress =
"+InetAddress.getByName("yahoo.com").toString());
} catch (Exception e) {
e.printStackTrace();
}
}
}
---

Compile this way:
javac -target 1.4 -source 1.4 HostQuery.java

If you are getting the UnknownHostException the above will print the
full stack trace and will help us debug. Make sure to use a debug build
and then copy & paste the entire stack trace in your response.

Here's what I get running a plain CVM CDC/FP build on a Linux/x86 system:

ping yahoo.com
PING yahoo.com (66.94.234.13) 56(84) bytes of data.
64 bytes from w2.rc.vip.scd.yahoo.com (66.94.234.13): icmp_seq=2 ttl=46
time=5.19 ms
64 bytes from w2.rc.vip.scd.yahoo.com (66.94.234.13): icmp_seq=3 ttl=47
time=4.50 ms

--- yahoo.com ping statistics ---
3 packets transmitted, 2 received, 33% packet loss, time 2000ms
rtt min/avg/max/mdev = 4.506/4.848/5.191/0.349 ms

cvm -version
Product: CDC (1.1.2_02-b03)
Profile: CDC 1.1.2_02 (Specification 1.1.2)
JVM: CDC 1.1.2_02-b03 (interpreter loop)

cvm -cp . HostQuery
getAddress = yahoo.com/216.109.112.135

Also, you might want to check your /etc/resolv.conf. Is it set correctly?

Example:

cat /etc/resolv.conf
search SFBay.Sun.COM sun.com
nameserver 129.145.154.118
nameserver 129.145.155.220
nameserver 129.147.9.5

Please copy & paste your /etc/resolve.conf contents also.

Thanks,

Hinkmond

---------------------------------------------------------------------
To unsubscribe, e-mail: advanced-unsubscribe@phoneme.dev.java.net
For additional commands, e-mail: advanced-help@phoneme.dev.java.net