Discussion:
illegal instruction on atan2
(too old to reply)
Alexandre Bencz
2023-05-22 15:40:01 UTC
Permalink
I'm testing an Uber lib, for geo indexing, that performs thousands of
geospatial calculations... during the tests, when compiling the project,
I received an illegal instruction error for absolute all the testes...,
after some investigations, I identified that the failure occurred in the
__atan2

C [libm.so.6+0x402e8] __atan2_finite+0xfff92ac0

Here they are, the related issues in the respective projects:

* https://github.com/uber/h3/issues/769
* https://github.com/uber/h3-java/issues/133

At now, I'm testing on QEMU with last Debian Port image:
Also, I did the same test on IBM Power5 - 9111-520 and on Power Mac G5,
the same error happens :/

|$ uname -a Linux debian 6.1.0-9-powerpc64 #1 SMP Debian 6.1.27-1
(2023-05-08) ppc64 GNU/Linux $ lscpu Architecture: ppc64 CPU op-mode(s):
32-bit, 64-bit Byte Order: Big Endian CPU(s): 12 On-line CPU(s) list:
0-11 Model name: POWER7 (architected), altivec supported Model: 2.1 (pvr
004a 0201) Thread(s) per core: 1 Core(s) per socket: 12 Socket(s): 1
Virtualization features: Hypervisor vendor: KVM Virtualization type:
para Caches (sum of all): L1d: 384 KiB (12 instances) L1i: 384 KiB (12
instances) NUMA: NUMA node(s): 1 NUMA node0 CPU(s): 0-11
Vulnerabilities: Itlb multihit: Not affected L1tf: Mitigation; RFI Flush
Mds: Not affected Meltdown: Mitigation; RFI Flush Mmio stale data: Not
affected Retbleed: Not affected Spec store bypass: Mitigation; Kernel
entry/exit barrier (fallback) Spectre v1: Mitigation; __user pointer
sanitization, ori31 speculat ion barrier enabled Spectre v2: Mitigation;
Software count cache flush (hardware accele rated), Software link stack
flush Srbds: Not affected Tsx async abort: Not affected |
Alexandre Bencz
2023-05-22 16:30:01 UTC
Permalink
I did some analysis here... I identified exactly where the error is
occurring:

gdb --args ./bin/latLngToCell --resolution 10 --latitude 40.689167
--longitude -74.044444
GNU gdb (Debian 13.1-3) 13.1
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "powerpc64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./bin/latLngToCell...
(gdb) run
Starting program: /home/bencz/h3/build/bin/latLngToCell --resolution 10
--latitude 40.689167 --longitude -74.044444
[Thread debugging using libthread_db enabled]
Using host libthread_db library
"/lib/powerpc64-linux-gnu/libthread_db.so.1".

Program received signal SIGILL, Illegal instruction.
__cos (x=0.7101599340438236) at ../sysdeps/ieee754/dbl-64/s_sin.c:272
272     ../sysdeps/ieee754/dbl-64/s_sin.c: No such file or directory.
(gdb) bt full
#0  __cos (x=0.7101599340438236) at ../sysdeps/ieee754/dbl-64/s_sin.c:272
        y = <optimized out>
        a = 6.9533558075373792e-310
        da = 6.953355807549632e-310
        u = <optimized out>
        k = <optimized out>
        m = <optimized out>
        n = <optimized out>
        retval = 0
        ctx = <optimized out>
#1  0x0000000100013554 in _geoToVec3d (geo=0x7fffffffeb80,
v=0x7fffffffe878) at /home/bencz/h3/src/h3lib/lib/vec3d.c:51
        r = 0
#2  0x000000010000bdc4 in _geoToClosestFace (g=0x7fffffffeb80,
face=0x7fffffffeac8, sqd=0x7fffffffe970) at
/home/bencz/h3/src/h3lib/lib/faceijk.c:938
        v3d = {x = 2.1995190125098354e-106, y =
6.9533491603584174e-310, z = 0}
#3  0x000000010000bb44 in _geoToHex2d (g=0x7fffffffeb80, res=10,
face=0x7fffffffeac8, v=0x7fffffffea20) at
/home/bencz/h3/src/h3lib/lib/faceijk.c:392
        sqd = 0
        r = 0
        theta = 0
#4  0x000000010000bacc in _geoToFaceIjk (g=0x7fffffffeb80, res=10,
h=0x7fffffffeac8) at /home/bencz/h3/src/h3lib/lib/faceijk.c:374
        v = {x = 0, y = 0}
#5  0x000000010000825c in latLngToCell (g=0x7fffffffeb80, res=10,
out=0x7fffffffeb78) at /home/bencz/h3/src/h3lib/lib/h3Index.c:784
        fijk = {face = 32767, coord = {i = -5424, j = 32767, k = -5200}}
#6  0x0000000100004428 in doCoords (lat=40.689166999999998,
lng=-74.044443999999999, res=10) at
/home/bencz/h3/src/apps/filters/latLngToCell.c:51
        g = {lat = 0.7101599340438236, lng = -1.2923193406085602}
        h = 4295059370
        e = 0
#7  0x0000000100004704 in main (argc=7, argv=0x7ffffffff328) at
/home/bencz/h3/src/apps/filters/latLngToCell.c:102
        res = 10
        lat = 40.689166999999998
        lng = -74.044443999999999
        helpArg = {names = {0x1000166b8 "-h", 0x1000166bb "--help"},
required = false, scanFormat = 0x0, valueName = 0x0, value = 0x0, found
= false, helpText = 0x1000166c2 "Show this help message."}
        resArg = {names = {0x1000166da "-r", 0x1000166dd
"--resolution"}, required = true, scanFormat = 0x1000166ea "%d",
valueName = 0x1000166ed "res", value = 0x7fffffffee74, found = true,
helpText = 0x1000166f1 "Resolution, 0-15 inclusive."}
        latArg = {names = {0x10001670d "--lat", 0x100016713
"--latitude"}, required = false, scanFormat = 0x10001682b "%lf",
valueName = 0x10001670f "lat", value = 0x7fffffffee68, found = true,
          helpText = 0x10001671e "Latitude in degrees. If not
specified, \"latitude longitude\" pairs will be read from standard input."}
        lngArg = {names = {0x100016782 "--lng", 0x100016788
"--longitude"}, required = false, scanFormat = 0x10001682b "%lf",
valueName = 0x100016784 "lng", value = 0x7fffffffee60, found = true,
helpText = 0x100016794 "Longitude in degrees."}
        args = {0x7fffffffee20, 0x7fffffffede0, 0x7fffffffeda0,
0x7fffffffed60}
        numArgs = 4
        helpText = 0x1000167aa "Convert degrees latitude/longitude
coordinates to H3 indexes."
0x7ffff7ed8fec <__cos+28>        mffscrni f0,0
Jeffrey Walton
2023-05-22 17:20:01 UTC
Permalink
Post by Alexandre Bencz
I did some analysis here... I identified exactly where the error is
gdb --args ./bin/latLngToCell --resolution 10 --latitude 40.689167
--longitude -74.044444
GNU gdb (Debian 13.1-3) 13.1
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "powerpc64-linux-gnu".
Type "show configuration" for configuration details.
<https://www.gnu.org/software/gdb/bugs/>.
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./bin/latLngToCell...
(gdb) run
Starting program: /home/bencz/h3/build/bin/latLngToCell --resolution 10
--latitude 40.689167 --longitude -74.044444
[Thread debugging using libthread_db enabled]
Using host libthread_db library
"/lib/powerpc64-linux-gnu/libthread_db.so.1".
Program received signal SIGILL, Illegal instruction.
__cos (x=0.7101599340438236) at ../sysdeps/ieee754/dbl-64/s_sin.c:272
272 ../sysdeps/ieee754/dbl-64/s_sin.c: No such file or directory.
(gdb) bt full
#0 __cos (x=0.7101599340438236) at ../sysdeps/ieee754/dbl-64/s_sin.c:272
y = <optimized out>
a = 6.9533558075373792e-310
da = 6.953355807549632e-310
u = <optimized out>
k = <optimized out>
m = <optimized out>
n = <optimized out>
retval = 0
ctx = <optimized out>
#1 0x0000000100013554 in _geoToVec3d (geo=0x7fffffffeb80,
v=0x7fffffffe878) at /home/bencz/h3/src/h3lib/lib/vec3d.c:51
r = 0
#2 0x000000010000bdc4 in _geoToClosestFace (g=0x7fffffffeb80,
face=0x7fffffffeac8, sqd=0x7fffffffe970) at
/home/bencz/h3/src/h3lib/lib/faceijk.c:938
v3d = {x = 2.1995190125098354e-106, y =
6.9533491603584174e-310, z = 0}
#3 0x000000010000bb44 in _geoToHex2d (g=0x7fffffffeb80, res=10,
face=0x7fffffffeac8, v=0x7fffffffea20) at
/home/bencz/h3/src/h3lib/lib/faceijk.c:392
sqd = 0
r = 0
theta = 0
#4 0x000000010000bacc in _geoToFaceIjk (g=0x7fffffffeb80, res=10,
h=0x7fffffffeac8) at /home/bencz/h3/src/h3lib/lib/faceijk.c:374
v = {x = 0, y = 0}
#5 0x000000010000825c in latLngToCell (g=0x7fffffffeb80, res=10,
out=0x7fffffffeb78) at /home/bencz/h3/src/h3lib/lib/h3Index.c:784
fijk = {face = 32767, coord = {i = -5424, j = 32767, k = -5200}}
#6 0x0000000100004428 in doCoords (lat=40.689166999999998,
lng=-74.044443999999999, res=10) at
/home/bencz/h3/src/apps/filters/latLngToCell.c:51
g = {lat = 0.7101599340438236, lng = -1.2923193406085602}
h = 4295059370
e = 0
#7 0x0000000100004704 in main (argc=7, argv=0x7ffffffff328) at
/home/bencz/h3/src/apps/filters/latLngToCell.c:102
res = 10
lat = 40.689166999999998
lng = -74.044443999999999
helpArg = {names = {0x1000166b8 "-h", 0x1000166bb "--help"},
required = false, scanFormat = 0x0, valueName = 0x0, value = 0x0, found
= false, helpText = 0x1000166c2 "Show this help message."}
resArg = {names = {0x1000166da "-r", 0x1000166dd
"--resolution"}, required = true, scanFormat = 0x1000166ea "%d",
valueName = 0x1000166ed "res", value = 0x7fffffffee74, found = true,
helpText = 0x1000166f1 "Resolution, 0-15 inclusive."}
latArg = {names = {0x10001670d "--lat", 0x100016713
"--latitude"}, required = false, scanFormat = 0x10001682b "%lf",
valueName = 0x10001670f "lat", value = 0x7fffffffee68, found = true,
helpText = 0x10001671e "Latitude in degrees. If not
specified, \"latitude longitude\" pairs will be read from standard input."}
lngArg = {names = {0x100016782 "--lng", 0x100016788
"--longitude"}, required = false, scanFormat = 0x10001682b "%lf",
valueName = 0x100016784 "lng", value = 0x7fffffffee60, found = true,
helpText = 0x100016794 "Longitude in degrees."}
args = {0x7fffffffee20, 0x7fffffffede0, 0x7fffffffeda0,
0x7fffffffed60}
numArgs = 4
helpText = 0x1000167aa "Convert degrees latitude/longitude
coordinates to H3 indexes."
0x7ffff7ed8fec <__cos+28> mffscrni f0,0
mffscrni is POWER9.

Maybe https://www.mail-archive.com/qemu-***@nongnu.org/msg959063.html
is related?

Jeff
Alexandre Bencz
2023-05-22 17:40:01 UTC
Permalink
Yeah... Looks like the libm was compiled for Power9 (it just looks...)

It doesn't seem to be related... if it is possible, for someone, to test
it on a real hardware...
if this error not happens on real hardware.... the qemu problem can be
defined as related ....
Unfortunately my Power computers are all off :(
Post by Jeffrey Walton
Post by Alexandre Bencz
I did some analysis here... I identified exactly where the error is
gdb --args ./bin/latLngToCell --resolution 10 --latitude 40.689167
--longitude -74.044444
GNU gdb (Debian 13.1-3) 13.1
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "powerpc64-linux-gnu".
Type "show configuration" for configuration details.
<https://www.gnu.org/software/gdb/bugs/>.
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./bin/latLngToCell...
(gdb) run
Starting program: /home/bencz/h3/build/bin/latLngToCell --resolution 10
--latitude 40.689167 --longitude -74.044444
[Thread debugging using libthread_db enabled]
Using host libthread_db library
"/lib/powerpc64-linux-gnu/libthread_db.so.1".
Program received signal SIGILL, Illegal instruction.
__cos (x=0.7101599340438236) at ../sysdeps/ieee754/dbl-64/s_sin.c:272
272 ../sysdeps/ieee754/dbl-64/s_sin.c: No such file or directory.
(gdb) bt full
#0 __cos (x=0.7101599340438236) at ../sysdeps/ieee754/dbl-64/s_sin.c:272
y = <optimized out>
a = 6.9533558075373792e-310
da = 6.953355807549632e-310
u = <optimized out>
k = <optimized out>
m = <optimized out>
n = <optimized out>
retval = 0
ctx = <optimized out>
#1 0x0000000100013554 in _geoToVec3d (geo=0x7fffffffeb80,
v=0x7fffffffe878) at /home/bencz/h3/src/h3lib/lib/vec3d.c:51
r = 0
#2 0x000000010000bdc4 in _geoToClosestFace (g=0x7fffffffeb80,
face=0x7fffffffeac8, sqd=0x7fffffffe970) at
/home/bencz/h3/src/h3lib/lib/faceijk.c:938
v3d = {x = 2.1995190125098354e-106, y =
6.9533491603584174e-310, z = 0}
#3 0x000000010000bb44 in _geoToHex2d (g=0x7fffffffeb80, res=10,
face=0x7fffffffeac8, v=0x7fffffffea20) at
/home/bencz/h3/src/h3lib/lib/faceijk.c:392
sqd = 0
r = 0
theta = 0
#4 0x000000010000bacc in _geoToFaceIjk (g=0x7fffffffeb80, res=10,
h=0x7fffffffeac8) at /home/bencz/h3/src/h3lib/lib/faceijk.c:374
v = {x = 0, y = 0}
#5 0x000000010000825c in latLngToCell (g=0x7fffffffeb80, res=10,
out=0x7fffffffeb78) at /home/bencz/h3/src/h3lib/lib/h3Index.c:784
fijk = {face = 32767, coord = {i = -5424, j = 32767, k = -5200}}
#6 0x0000000100004428 in doCoords (lat=40.689166999999998,
lng=-74.044443999999999, res=10) at
/home/bencz/h3/src/apps/filters/latLngToCell.c:51
g = {lat = 0.7101599340438236, lng = -1.2923193406085602}
h = 4295059370
e = 0
#7 0x0000000100004704 in main (argc=7, argv=0x7ffffffff328) at
/home/bencz/h3/src/apps/filters/latLngToCell.c:102
res = 10
lat = 40.689166999999998
lng = -74.044443999999999
helpArg = {names = {0x1000166b8 "-h", 0x1000166bb "--help"},
required = false, scanFormat = 0x0, valueName = 0x0, value = 0x0, found
= false, helpText = 0x1000166c2 "Show this help message."}
resArg = {names = {0x1000166da "-r", 0x1000166dd
"--resolution"}, required = true, scanFormat = 0x1000166ea "%d",
valueName = 0x1000166ed "res", value = 0x7fffffffee74, found = true,
helpText = 0x1000166f1 "Resolution, 0-15 inclusive."}
latArg = {names = {0x10001670d "--lat", 0x100016713
"--latitude"}, required = false, scanFormat = 0x10001682b "%lf",
valueName = 0x10001670f "lat", value = 0x7fffffffee68, found = true,
helpText = 0x10001671e "Latitude in degrees. If not
specified, \"latitude longitude\" pairs will be read from standard input."}
lngArg = {names = {0x100016782 "--lng", 0x100016788
"--longitude"}, required = false, scanFormat = 0x10001682b "%lf",
valueName = 0x100016784 "lng", value = 0x7fffffffee60, found = true,
helpText = 0x100016794 "Longitude in degrees."}
args = {0x7fffffffee20, 0x7fffffffede0, 0x7fffffffeda0,
0x7fffffffed60}
numArgs = 4
helpText = 0x1000167aa "Convert degrees latitude/longitude
coordinates to H3 indexes."
0x7ffff7ed8fec <__cos+28> mffscrni f0,0
mffscrni is POWER9.
is related?
Jeff
John Paul Adrian Glaubitz
2023-05-22 17:50:01 UTC
Permalink
Post by Alexandre Bencz
Yeah... Looks like the libm was compiled for Power9 (it just looks...)
I am quite confident that this is not the case.

Aurelien takes great care in defining the baseline when configuring glibc for a given architecture.
Post by Alexandre Bencz
Unfortunately my Power computers are all off :(
I thought you tested on a real PowerMac G5?

If you tested on QEMU only, it’s quite obvious that’s it’s the bug report that Jeffrey referenced above.

Adrian
Alexandre Bencz
2023-05-24 20:20:01 UTC
Permalink
Nice, I did the test in the real Mac G5... and, works fine!!
Post by John Paul Adrian Glaubitz
Post by Alexandre Bencz
Yeah... Looks like the libm was compiled for Power9 (it just looks...)
I am quite confident that this is not the case.
Aurelien takes great care in defining the baseline when configuring glibc for a given architecture.
Post by Alexandre Bencz
Unfortunately my Power computers are all off :(
I thought you tested on a real PowerMac G5?
If you tested on QEMU only, it’s quite obvious that’s it’s the bug report that Jeffrey referenced above.
Adrian
Loading...