Page 1 sur 2

segfaults on several non-x86 architectures

Publié : mer. févr. 22, 2017 2:03 pm
par infinity0
Here is the report in Debian: https://bugs.debian.org/cgi-bin/bugrepo ... bug=855078

I have added some debugging details on that report - it seems there is some inconsistency (on the same architecture) whether SMARTPTR64 is defined or not in that architecture.

You can see the exact build failure logs here: https://buildd.debian.org/status/package.php?p=giac

For example: https://buildd.debian.org/status/fetch. ... 8475&raw=0 or set raw=1 to download the plain text.

I understand that these are low-priority architectures, so there is no rush, take your time. In Debian we try to support quite a lot of architectures but we understand not all projects have the resources for this, and it is less important for end applications (that have fewer build-dependants).

Re: segfaults on several non-x86 architectures

Publié : ven. févr. 24, 2017 6:43 am
par parisse
I can not fix myself if I don't have access to one of these archs. src/first.h should indeed not undef SMARTPTR64, it should undef it for 32 bit archs, but I don't know how to check that properly.

Re: segfaults on several non-x86 architectures

Publié : ven. févr. 24, 2017 7:06 am
par parisse
Perhaps

Code : Tout sélectionner

#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) &&     !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
#define SMARTPTR64
#else // __x86_64__
#ifdef SMARTPTR64
#undef SMARTPTR64
#endif // SMARTPTR64
#ifdef _I386_
#undef _I386_
#endif // _I386_
#endif // __x86_64__
would work?

Re: segfaults on several non-x86 architectures

Publié : sam. mars 11, 2017 4:34 pm
par infinity0
Unfortunately this does not work either, the segfault still occurs.

Is there a way to bypass SMARTPTR64 and just use normal pointers?

Also what is the purpose of this:

Code : Tout sélectionner

#undef _I386_

Re: segfaults on several non-x86 architectures

Publié : sam. mars 11, 2017 5:43 pm
par parisse
What happens if you define -DDOUBLEVAL (or in config.h)? This force representing double without truncation and therefore gen are using normal pointers.
If my recollection is correct, #undef _I386_ avoids using some i386 assembly code.

Re: segfaults on several non-x86 architectures

Publié : mer. mars 15, 2017 9:38 am
par parisse
The geogebra team had the same problem with arm64, and we made some progresses thanks to arm64 emulation http://www.ecliptik.com/Emulating-ARM64-on-Linux/. It seems the segfault happens only if you link icas/xcas with the dynamic libgiac.so, in that case ./icas '2+2' segfaults. If you link statically with libgiac.a instead, then icas works, I already checked a few regression tests (it's sometimes very slow with arm64 emulation...).
This is perhaps related to the order ld is using to load object files, it's possible that some static initializations in some object files must be done after other initializations.

Re: segfaults on several non-x86 architectures

Publié : jeu. mars 16, 2017 9:58 am
par parisse
I confirm that I get a working icas with

Code : Tout sélectionner

./configure --enable-shared=no
I guess it's possible to use this workaround to build giac debian packages on arm64 architectures.

Re: segfaults on several non-x86 architectures

Publié : lun. mars 20, 2017 9:13 am
par frederic han
Hi bernard,
there are also some debugging sessions in this sage ticket:
https://trac.sagemath.org/ticket/22280

on ppc64 in comment 25 compiled statically doesn't look better.

Re: segfaults on several non-x86 architectures

Publié : lun. mars 20, 2017 9:34 am
par parisse
Like for arm64, I can't fix anything myself if I don't have access to a system like that, the stack trace is not really useful.
Fortunately, ppc64 is not as popular as arm64.

Re: segfaults on several non-x86 architectures

Publié : ven. mars 24, 2017 10:38 am
par frederic han
I have tried with qemu on a debian stable:
with giac source 1.2.3-31
(so I have only 1core and the thread value is 1)

Code : Tout sélectionner

Linux debianppc64 3.16.0-4-powerpc64le #1 SMP Debian 3.16.39-1+deb8u2 (2017-03-07) ppc64le GNU/Linux
I have just built giac with libgmp-dev and libmpfr-dev.
with the default compiler (gcc-4.9) I was able to reproduce the problem (1+1 crashes and also: e) with a similar debug session as infinity0.

But I tried again with gcc-4.8 and now it works...

Re: segfaults on several non-x86 architectures

Publié : dim. mai 28, 2017 8:01 am
par infinity0
Some more info here: https://bugs.debian.org/cgi-bin/bugrepo ... =855078#19

There is apparently misuse of the __x86_64__ macro throughout the code.

Re: segfaults on several non-x86 architectures

Publié : dim. mai 28, 2017 8:07 am
par infinity0
Most portable is probably to check sizeof(void*) == 4 or 8 rather than the architecture specifically.

Re: segfaults on several non-x86 architectures

Publié : dim. mai 28, 2017 2:02 pm
par parisse
Ok, I will define SMARTPTR64 only if sizeof(void *)==8. I'm also modifying in gen.h with ~(uintptr_t)3 instead of 0xf...fffc. This will perhaps fix the dynamic arm64 binaries. I'll make a source distribution next week.

Re: segfaults on several non-x86 architectures

Publié : mar. mai 30, 2017 11:46 am
par parisse
I have updated giac_stable to giac-1.2.3-47. The dynamic binary is (almost) working on my qemu arm64: by almost, I mean that some regression tests seems to run indefinitely, but a native run would perhaps finish.

Re: segfaults on several non-x86 architectures

Publié : sam. juin 24, 2017 1:42 pm
par infinity0
Thanks, that seems to be fixed, all tests are passing for me on arm64 with 1.2.3-51.

However the Sage folks are reporting that it's necessary to give

Code : Tout sélectionner

-Dx86_64
on ppc64. (I haven't yet tested this myself though.)