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

Problem running under Linux #28

Closed
sv1 opened this issue Jul 4, 2018 · 8 comments
Closed

Problem running under Linux #28

sv1 opened this issue Jul 4, 2018 · 8 comments

Comments

@sv1
Copy link

sv1 commented Jul 4, 2018

For some strange reason I can not run JAERO 1.4.0.7 under Linux

(gdb) r
Starting program: /opt/linux/JAERO/JAERO/JAERO
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffe9b65700 (LWP 3468)]
[New Thread 0x7fffe8f4f700 (LWP 3469)]
[New Thread 0x7fffcffff700 (LWP 3470)]
[New Thread 0x7fffcf7fe700 (LWP 3471)]
[New Thread 0x7fffceffd700 (LWP 3472)]
[New Thread 0x7fffce7fc700 (LWP 3473)]
[New Thread 0x7fffcdffb700 (LWP 3474)]
[New Thread 0x7fffcd7fa700 (LWP 3475)]

Thread 1 "JAERO" received signal SIGILL, Illegal instruction.
0x00007ffff7bd421f in fill_table () from /usr/local/lib/libcorrect.so

@sv1 sv1 changed the title Problem compiling under Linux Problem running under Linux Jul 4, 2018
@jontio
Copy link
Owner

jontio commented Jul 6, 2018

Strange. I tried a VM with uname -a == Linux qos 4.9.0-5-amd64 #1 SMP Debian 4.9.65-3+deb9u2 (2018-01-04) x86_64 GNU/Linux. The processor was an Intel G3220 and knows MMX,SSE,SSE2,SSE3,SSE4.1,SSE4.2,EM64T and VT-x.

I compiled JAERO then libcorrect. I cloned JAERO ( git clone https://github.com/jontio/JAERO.git ) as it is the same as version 1.4.0.7. I had to add LIBS += -lcorrect to the JAERO.pro file. libcorrect was the one than is in the JAERO repo. I then installed the libcorrect library. I then ran gdb, set the exe file and ran, waited for a bit then quit JAERO...

(gdb) exec-file ./JAERO
(gdb) r
Starting program: /home/jonti/Desktop/JAERO/JAERO/JAERO JAERO
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffe9b7d700 (LWP 20700)]
[New Thread 0x7fffe3fff700 (LWP 20701)]
[New Thread 0x7fffe37fe700 (LWP 20702)]
PulseAudioService: pa_context_connect() failed
[Thread 0x7fffe37fe700 (LWP 20702) exited]
[New Thread 0x7fffe37fe700 (LWP 20704)]
[New Thread 0x7fffe2ffd700 (LWP 20705)]
[New Thread 0x7fffe27fc700 (LWP 20706)]
[New Thread 0x7fffe1ffb700 (LWP 20707)]
[Thread 0x7fffe37fe700 (LWP 20704) exited]
using null input device, none available
using null input device, none available
using null input device, none available
using null input device, none available
[Thread 0x7fffe27fc700 (LWP 20706) exited]
[Thread 0x7fffe1ffb700 (LWP 20707) exited]
[Thread 0x7fffe2ffd700 (LWP 20705) exited]
[Thread 0x7fffe9b7d700 (LWP 20700) exited]
[Thread 0x7fffe3fff700 (LWP 20701) exited]
[Inferior 1 (process 20699) exited normally]
(gdb)  

So I didn't manage to get the illegal instruction in libcorrect's filltable function.

What libcorrect version did you use? The one with JAERO or the latest one from https://github.com/quiet/libcorrect ?

@sv1
Copy link
Author

sv1 commented Jul 7, 2018 via email

@unixpunk
Copy link

unixpunk commented Jul 8, 2018

I vaguely remember having a similar issue when there is no input sound device available on the system. HTH

@sv1
Copy link
Author

sv1 commented Jul 8, 2018 via email

@jontio
Copy link
Owner

jontio commented Jul 8, 2018

It's hard to figure out what is going on when I can't reproduce the error. However what I think is happening is this...

Your CPU doesn't support SSE4.2. In SSE4.2 the instruction POPCNT was introduced that is a fast was of counting bits set to 1. In fill_table in lookup.c of libcorrect line 15 says out |= (popcount(i & poly[j]) % 2) ? mask : 0; . In portable.h we have

#ifdef __GNUC__
#define HAVE_BUILTINS
#endif


#ifdef HAVE_BUILTINS
#define popcount __builtin_popcount
#define prefetch __builtin_prefetch
#else

static inline int popcount(int x) {
    /* taken from the helpful http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel */
    x = x - ((x >> 1) & 0x55555555);
    x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
    return ((x + (x >> 4) & 0x0f0f0f0f) * 0x01010101) >> 24;
}

static inline void prefetch(void *x) {}

#endif

When you are running cmake GNUC will be true so HAVE_BUILTINS is true. I think gcc thinks you have SSE4.2 support and compiles __builtin_popcount as POPCNT rather than defining a function itself.

I don't know if that is a bug with gcc or not. When I tried to compile libcorrect on a pi I didn't get a POPCNT instruction used.

I think the easiest way to fix the problem would simply be masking out #define HAVE_BUILTINS in portable.h (change line 2 of portable.h to //#define HAVE_BUILTINS)

@sv1
Copy link
Author

sv1 commented Jul 9, 2018 via email

@jontio
Copy link
Owner

jontio commented Oct 7, 2019

Can you try typing gcc -mavx2 -dM -E - < /dev/null | egrep "SSE|AVX" | sort on your computer that doesn't have SSE4.2?

I tried it on a computer that didn't have AVX but still got...

#define __AVX__ 1
#define __AVX2__ 1
#define __SSE__ 1
#define __SSE_MATH__ 1
#define __SSE2__ 1
#define __SSE2_MATH__ 1
#define __SSE3__ 1
#define __SSE4_1__ 1
#define __SSE4_2__ 1
#define __SSSE3__ 1

So it's looking like that isn't a solution for libcorrect but worth a try at least.

@jontio
Copy link
Owner

jontio commented Oct 7, 2019

I think think problem has been raised and solved in libcorrect repo quiet/libcorrect#24 . Not sure how it works as I'm not that up to speed with cmake but interesting.

@jontio jontio closed this as completed Jan 12, 2020
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

3 participants