Description
Hi all,
I discovered this issue while working with a Python library that uses a rust binary, and I don't really speak rust at all. The original issue filed with the Python library can be found here.
The Python library in question takes in an OSGB36 coordinate pair, calls a rust binary to performs conversion to a WGS84 coordinate pair, and returns the result via the Python interface. The problem seems to have happened at the rust binary used by the library, whose source code can be found at here.
The Python code reproducing the issue is as followed:
from convertbng.util import convert_lonlat, convert_bng
from numpy import isnan
def bng_to_longlat(bng):
""" Given a pair of BNG coordinates return its long and lat coordinates. """
try:
easting = [int(bng[0])]
northing = [int(bng[1])]
coordinates = convert_lonlat(easting, northing)
coordinate_long = coordinates[0][0]
coordinate_lat = coordinates[1][0]
if isnan(coordinate_long) or isnan(coordinate_lat):
return False
return (coordinate_long, coordinate_lat)
except ValueError:
return False
print bng_to_longlat((315877,781709))
print convert_bng([-7.30034511], [49.95888852])
When executed on my Intel i5-3570S system, the Python interpreter will return the followed message:
Illegal instruction (core dumped)
Which is also logged by the kernel in /var/log/syslog
:
Feb 27 18:28:37 {hostname} kernel: [252228.554877] traps: python[25185] trap invalid opcode ip:7f5dfad3b8f2 sp:7ffd3af2d588 error:0 in liblonlat_bng-783571af.so[7f5dfacd2000+1d2a000]
This issue happened on a very specific CPU:
OS: Ubuntu 16.04.2 LTS 64bit
CPU: Intel i5-3570S
Kernel: Linux 4.4.0-64-generic #85-Ubuntu
With both Ubuntu 16.04 LTS and 14.04 LTS, on a range of CPUs including i7-6600, E3-1225v2, a QEMU virtual CPU on a KVM VPS (underlying hardware unknown) and i5-4210U, this error cannot be reproduced. Therefore it seems to be limited to Intel i5-3570S and maybe a few other processors.
We also tried to build lonlat_bng
on various platforms. The tests did fail on i7-6600 Ubuntu 16.04 and i5-4210U Arch, but the Python script could execute the rust binary provided by convertbng
correctly on these two platforms:
---- conversions::tests::test_convert_osgb36_to_ll stdout ----
thread 'conversions::tests::test_convert_osgb36_to_ll' panicked at 'called `Result::unwrap()` on an `Err` value: ()', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libcore/result.rs:837
Many thanks.