Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 312457 - Exception in LocatorService.Subnet.contains
Summary: Exception in LocatorService.Subnet.contains
Status: RESOLVED FIXED
Alias: None
Product: TCF
Classification: Tools
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 blocker (vote)
Target Milestone: 0.4.0   Edit
Assignee: Project Inbox CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords:
: 313778 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-05-11 11:55 EDT by Ken Ryall CLA
Modified: 2013-06-05 07:56 EDT (History)
3 users (show)

See Also:


Attachments
Screen shot showing stack and variable values. (170.19 KB, image/png)
2010-05-11 11:55 EDT, Ken Ryall CLA
no flags Details
buf contents (50.24 KB, image/png)
2010-05-12 18:04 EDT, Ken Ryall CLA
no flags Details
screenshot showing variable values (15.37 KB, image/png)
2010-05-19 03:16 EDT, Ken Ryall CLA
no flags Details
suggested patch (931 bytes, patch)
2010-05-19 03:18 EDT, Ken Ryall CLA
mober.at+eclipse: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ken Ryall CLA 2010-05-11 11:55:30 EDT
Created attachment 167950 [details]
Screen shot showing stack and variable values.

I'm getting an ArrayIndexOutOfBounds exception in LocatorService.Subnet.contains. It looks like it is running into trouble comparing an Inet4Address with an Inet6Address.

See the attached screen shot for more details.

I would attempt a fix but I'm not sure exactly how this is supposed to work.
Comment 1 Eugene Tarassov CLA 2010-05-11 15:29:47 EDT
I have committed a fix.
I don't have Windows 7, so I tested it on Windows XP with IP V6 installed.

Thanks.
Comment 2 Ken Ryall CLA 2010-05-12 18:03:33 EDT
Eugene, I'm having a problem with the fix on Windows 7. See the attached screenshot: at line 510 the buf length is 16. Consequently the subnet isn't added and my client on the local machine doesn't get the peer added notification.
Comment 3 Ken Ryall CLA 2010-05-12 18:04:20 EDT
Created attachment 168285 [details]
buf contents
Comment 4 Eugene Tarassov CLA 2010-05-12 18:51:03 EDT
(In reply to comment #2)
> Eugene, I'm having a problem with the fix on Windows 7. See the attached
> screenshot: at line 510 the buf length is 16. Consequently the subnet isn't
> added and my client on the local machine doesn't get the peer added
> notification.

Hi Ken,

TCF discovery works only over IPv4 subnets. IPv6 is not supported yet.

The fix addresses the exception that happens when both IPv4 and IPv6 installed - which, I think, is default for Windows 7, but it was not meant to provide full IPv6 support. And such support is not really necessary as long as IPv4 is available.

Is IPv4 enabled on your machine?
Is firewall turned off?
Comment 5 Ken Ryall CLA 2010-05-13 03:18:05 EDT
(In reply to comment #4)
> (In reply to comment #2)
> > Eugene, I'm having a problem with the fix on Windows 7. See the attached
> > screenshot: at line 510 the buf length is 16. Consequently the subnet isn't
> > added and my client on the local machine doesn't get the peer added
> > notification.
> 
> Hi Ken,
> 
> TCF discovery works only over IPv4 subnets. IPv6 is not supported yet.
> 
> The fix addresses the exception that happens when both IPv4 and IPv6 installed
> - which, I think, is default for Windows 7, but it was not meant to provide
> full IPv6 support. And such support is not really necessary as long as IPv4 is
> available.
> 
> Is IPv4 enabled on your machine?
> Is firewall turned off?

I'm running Windows 7 with IPv6 disabled. It is enabled by default on Win 7, but I get the same results with it enabled. The firewall is off.

If I launch the C based TCF reference agent it's services are discovered correctly, it is only when I launch my Java based agent that I have this problem.

I'll keep digging and see if I can find out more. Prior to this change I was able to discover the agent, I assume because it created a subnet for the IPv6 address.
Comment 6 Ken Ryall CLA 2010-05-13 18:03:18 EDT
I've worked around the last issue I mentioned. Marking this fixed as the exception no longer occurs.
Comment 7 Ken Ryall CLA 2010-05-19 03:14:51 EDT
Found another case where this exception occurs. On Windows 7 again, this time with ipv6 enabled. See the screen shot: a1 and a2 are equal but the subnet's prefix length is 128.
Comment 8 Ken Ryall CLA 2010-05-19 03:16:13 EDT
Created attachment 169060 [details]
screenshot showing variable values
Comment 9 Ken Ryall CLA 2010-05-19 03:18:13 EDT
Created attachment 169061 [details]
suggested patch

Checking the array contents would be a good start, but if they are not equal you could still get the exception.
Comment 10 Eugene Tarassov CLA 2010-05-19 13:41:18 EDT
The patch does not address the root problem: 128 is invalid value for network_prefix_len of a IPv4 network address. I have searched Java bug database, and found that it is a known problem:

InterfaceAddress.getNetworkPrefixLength() does not conform to Javadoc
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6707289

The bug shows up only when IPv6 is enabled.
Unfortunately, it looks like the bug is not fixed in Java 1.6.

We need to come up with a workaround for broken InterfaceAddress.getNetworkPrefixLength().
Comment 11 Eugene Tarassov CLA 2010-05-19 14:13:41 EDT
I have committed a (partial) workaround. It assumes network prefix length 24 if getNetworkPrefixLength() returns invalid value.

If anyone has better workaround, please contribute it.
Comment 12 Eugene Tarassov CLA 2010-05-20 13:35:13 EDT
*** Bug 313778 has been marked as a duplicate of this bug. ***
Comment 13 Eugene Tarassov CLA 2010-06-30 17:34:30 EDT
Fixed.

For details, see bug 318260:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=318260
Comment 14 Martin Oberhuber CLA 2010-09-21 08:53:57 EDT
Comment on attachment 169061 [details]
suggested patch

Marking patch obsolete since it was not used.
Comment 15 Doug Schaefer CLA 2011-05-17 10:48:44 EDT
Moving bugs to new home for IP log.
Comment 16 Martin Oberhuber CLA 2013-06-05 06:26:01 EDT
Bulk change: Marking all bugs from the TM era (until June 2011) target 0.3