Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exceptions if python is built without ipv6 support. #515

Closed
wants to merge 2 commits into from

Conversation

Projects
None yet
3 participants
Fix exception at roscore startup if python has ipv6 disabled.
Admittedly a python bug, but the workaround is already present in other parts of this file.
@ros-pull-request-builder

This comment has been minimized.

Copy link
Member

ros-pull-request-builder commented Oct 24, 2014

Can one of the admins verify this patch?

if use_ipv6():
reverse_ips = [host[4][0] for host in socket.getaddrinfo(socket.gethostname(), 0, 0, 0, socket.SOL_TCP)]
else:
reverse_ips = [host[4][0] for host in socket.getaddrinfo(socket.gethostname(), 0, socket.AF_INET, 0, socket.SOL_TCP)]

This comment has been minimized.

Copy link
@dirk-thomas

dirk-thomas Oct 24, 2014

Member

This is the same way as it is already used in other parts of the code (

). The change looks good - was probably just forgotten in the original patch for IPv6.

@@ -90,7 +90,7 @@ def is_machine_local(machine):
:returns: True if machine is local and doesn't require remote login, ``bool``
"""
try:
machine_ips = [host[4][0] for host in socket.getaddrinfo(machine.address, 0, 0, 0, socket.SOL_TCP)]
machine_ips = [host[4][0] for host in socket.getaddrinfo(machine.address, 0, 0, 0, socket.SOL_TCP) if isinstance(host[4][0],str)]

This comment has been minimized.

Copy link
@dirk-thomas

dirk-thomas Oct 24, 2014

Member

What type is host[4][0] in your case? Are you using Python 2 or 3?

This comment has been minimized.

Copy link
@aballier

aballier Oct 27, 2014

Author Contributor

I tried with both 2.7.8 and 3.3.5 on my desktop (ipv6 enabled): they're 'str' with both;

however, on the board where i disabled ipv6, I get this:

Python 2.7.8 (default, Oct 24 2014, 15:09:35)
[GCC 4.8.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import socket
socket.has_ipv6
False
socket.getaddrinfo("localhost", 0, 0, 0, socket.SOL_TCP)
[(10, 1, 6, '', (10, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')), (2, 1, 6, '', ('127.0.0.1', 0))]

so here, host[4][0] is int, causing the exception.

it can be fixed on my side by removing the '::1 localhost' line in /etc/hosts though, so that python doesn't even try to look that up, but i thought it would be useful to make the code more robust too.

This comment has been minimized.

Copy link
@dirk-thomas

dirk-thomas Oct 27, 2014

Member

Can you please add a comment above the line describing that with IPv6 disabled the value type is int.

This comment has been minimized.

Copy link
@aballier

aballier Oct 28, 2014

Author Contributor

done

Fix exception at roslaunch startup if python is build without ipv6 su…
…pport.

A bit different than rosgraph fix because we do not have use_ipv6 here. See e.g. http://bugs.python.org/issue16208#msg178764

@aballier aballier force-pushed the aballier:rosgraph_noipv6 branch from ed1b75b to afe5742 Oct 28, 2014

@dirk-thomas

This comment has been minimized.

Copy link
Member

dirk-thomas commented Dec 10, 2014

Manually merged to address PEP8 issue: 2926581 f283fa9

@dirk-thomas dirk-thomas added the bug label Dec 10, 2014

@dirk-thomas

This comment has been minimized.

Copy link
Member

dirk-thomas commented Dec 10, 2014

This change breaks a unit test: http://jenkins.ros.org/job/devel-indigo-ros_comm/125/ARCH_PARAM=amd64,UBUNTU_PARAM=trusty,label=devel/testReport/unit.test_roslaunch_launch/TestRoslaunchLaunch/test_validate_master_launch/

@aballier Why does you patch use socket.gethostname() instead of hostname?

And changed it back to use hostname again: bb13439

dirk-thomas added a commit that referenced this pull request Dec 10, 2014

mjyc added a commit to mjyc/ros_comm that referenced this pull request Dec 10, 2014

Merge remote-tracking branch 'upstream/indigo-devel' into indigo-devel
* upstream/indigo-devel:
  fix regression of PR ros#515
  Adding support for fixed-width floating-point and integer array values as per issue ros#400
  Fix exception at roslaunch startup if python is build without ipv6 support.
  Fix exception at roscore startup if python has ipv6 disabled.
  use fileno comparison only as an alternative and when available
  fix removal of QueuedConnection leading to wrong subscriber count (fix ros#526)
  fix comment (fix ros#529)
  unregister statistics publisher
  Fix: TCPROS header validation crash when `callerid` header is not set
  avoid storing subscriber reference in SubscriberStatisticsLogger
  only create SubscriberStatisticsLogger when enabled
  make param functions thread-safe
  Do not use Python when building for Android
  Do not use ifaddrs on Android as it is not natively supported

rsinnet pushed a commit to MisoRobotics/ros_comm that referenced this pull request Jun 19, 2017

Merge remote-tracking branch 'upstream/indigo-devel' into indigo-devel
* upstream/indigo-devel:
  fix regression of PR ros#515
  Adding support for fixed-width floating-point and integer array values as per issue ros#400
  Fix exception at roslaunch startup if python is build without ipv6 support.
  Fix exception at roscore startup if python has ipv6 disabled.
  use fileno comparison only as an alternative and when available
  fix removal of QueuedConnection leading to wrong subscriber count (fix ros#526)
  fix comment (fix ros#529)
  unregister statistics publisher
  Fix: TCPROS header validation crash when `callerid` header is not set
  avoid storing subscriber reference in SubscriberStatisticsLogger
  only create SubscriberStatisticsLogger when enabled
  make param functions thread-safe
  Do not use Python when building for Android
  Do not use ifaddrs on Android as it is not natively supported
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.