id	summary	reporter	owner	description	type	status	priority	component	severity	resolution	keywords	cc
253	Making a quiet nan results in an infinite loop on a bifferboard	richi@…	xi	"I want to install ros (robot operating system) on a bifferboard running debian squeeze. I had the same problem also with lenny and ros electric. The bifferboard is a small device running a 486 compatible CPU at 140 MHz. I followed the tutorial on http://www.ros.org/wiki/fuerte/Installation/Debian and the first few steps work, but rosinstall always freezes. I can have it running for a week, and it just uses the CPU and only a small amount of memory.

Executing the following results in an infinite loop:
{{{
#rosinstall --catkin ~/ros-underlay http://ros.org/rosinstalls/fuerte-ros-base.rosinstall
}}}
When I terminate it with ctrl-c, I get the following call stack:

{{{
^CTraceback (most recent call last):
  File ""/usr/local/bin/rosinstall"", line 5, in <module>
    pkg_resources.run_script('rosinstall==0.6.17', 'rosinstall')
  File ""/usr/lib/python2.6/dist-packages/pkg_resources.py"", line 467, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File ""/usr/lib/python2.6/dist-packages/pkg_resources.py"", line 1200, in run_script
    execfile(script_filename, namespace, namespace)
  File ""/usr/local/lib/python2.6/dist-packages/rosinstall-0.6.17-py2.6.egg/EGG-INFO/scripts/rosinstall"", line 5, in <module>
    from rosinstall.rosinstall_cli import rosinstall_main
  File ""/usr/local/lib/python2.6/dist-packages/rosinstall-0.6.17-py2.6.egg/rosinstall/rosinstall_cli.py"", line 53, in <module>
    import yaml
  File ""/usr/local/lib/python2.6/dist-packages/yaml/__init__.py"", line 8, in <module>
    from loader import *
  File ""/usr/local/lib/python2.6/dist-packages/yaml/loader.py"", line 8, in <module>
    from constructor import *
  File ""/usr/local/lib/python2.6/dist-packages/yaml/constructor.py"", line 161, in <module>
    class SafeConstructor(BaseConstructor):
  File ""/usr/local/lib/python2.6/dist-packages/yaml/constructor.py"", line 257, in SafeConstructor
    inf_value *= inf_value
KeyboardInterrupt
}}}

The offending lines in /usr/local/lib/python2.6/dist-packages/yaml/constructor.py are as follows : 

{{{
        inf_value = 1e300
    while inf_value != inf_value*inf_value:
        inf_value *= inf_value
    nan_value = -inf_value/inf_value   # Trying to make a quiet NaN (like C99).
}}}

Might be because the bifferboard doesn't have an FPU?
https://sites.google.com/site/bifferboard/Home/howto/qemu

some more info that might be relevant:

{{{
# cat /proc/cpuinfo 
processor	: 0
vendor_id	: CyrixInstead
cpu family	: 4
model		: 1
model name	: Cx486SLC
stepping	: unknown
fdiv_bug	: yes
hlt_bug		: no
f00f_bug	: no
coma_bug	: no
fpu		: no
fpu_exception	: no
cpuid level	: -1
wp		: yes
flags		:
bogomips	: 49.15
clflush size	: 32
power management:

# python --version
Python 2.6.7

#python
>>> inf_value = 1e300
>>> print inf_value
1e+300
>>> print inf_value*inf_value
nan
>>> print inf_value != inf_value*inf_value
True

>>> inf_value *= inf_value
>>> print inf_value
nan
>>> print inf_value*inf_value
nan
>>> print inf_value != inf_value*inf_value
True

# apt-cache show python-yaml | grep Version
Version: 3.09-5
}}}

I'm not a pythong expert, but the above results look strange to me.
Executing it on my workstation, gives the results I would expect:

{{{
$ python --version
Python 2.7.3
$ python
>>> inf_value = 1e300
>>> print inf_value
1e+300
>>> print inf_value*inf_value
inf
>>> print inf_value != inf_value*inf_value
True
>>> inf_value *= inf_value
>>> print inf_value != inf_value*inf_value
False
}}}

Comparing the two, It looks like the bifferboard has no inf in addition to strangely handling nan. I don't know If python should handle that and how. But it might be good, if yaml prepared for such cpu's. 

I applied a quick hack, as I don't think I'll use nan or inf on that device. I don't think that's a good solution, but it's better than an infinite loop.
{{{
    inf_value = 1e300
    loop_count = 10
    while inf_value != inf_value*inf_value and loop_count > 0:
        inf_value *= inf_value
        loop_count -= 1
    nan_value = -inf_value/inf_value   # Trying to make a quiet NaN (like C99).
}}}

"	defect	new	normal	pyyaml	normal		nan	
