Skip to content

Illegal Instruction on Intel i5-3570S #40125

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

Closed
chongyangshi opened this issue Feb 27, 2017 · 5 comments
Closed

Illegal Instruction on Intel i5-3570S #40125

chongyangshi opened this issue Feb 27, 2017 · 5 comments

Comments

@chongyangshi
Copy link

chongyangshi commented Feb 27, 2017

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.

@chongyangshi
Copy link
Author

Original issue: #urschrei/convertbng/issues/2
Library author: @urschrei

@retep998
Copy link
Member

Note that Rust will use intrinsics::abort() in certain places, such as out of memory or stack overflow, which emits a ud2 instruction resulting in an illegal instruction. So the majority of the time the actual codegen is fine, and the real problem is somewhere else.

@urschrei
Copy link
Contributor

Building lonlat_bng from sources will currently fail, as I neglected to pin a dependency, which I should probably fix.

@urschrei
Copy link
Contributor

Running cargo clean && cargo update should pull in a fixed-up dependency, @icydoge. You can then run cargo test. Note that you'll need at least 4GB of RAM (ideally more).

@alexcrichton
Copy link
Member

Thanks for the update @urschrei! Sounds like it was a local issue, so closing opportunistically in favor of that. If it's still an issue though @icydoge feel free to just ping this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants