segfaults on several non-x86 architectures

Librairie C++ de calcul formel/ C++ symbolic computation library

Modérateur : xcasadmin

infinity0
Messages : 36
Inscription : dim. févr. 05, 2017 5:46 pm

segfaults on several non-x86 architectures

Message par infinity0 » mer. févr. 22, 2017 2:03 pm

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).

parisse
Messages : 5084
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: segfaults on several non-x86 architectures

Message par parisse » ven. févr. 24, 2017 6:43 am

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.

parisse
Messages : 5084
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: segfaults on several non-x86 architectures

Message par parisse » ven. févr. 24, 2017 7:06 am

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?

infinity0
Messages : 36
Inscription : dim. févr. 05, 2017 5:46 pm

Re: segfaults on several non-x86 architectures

Message par infinity0 » sam. mars 11, 2017 4:34 pm

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_

parisse
Messages : 5084
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: segfaults on several non-x86 architectures

Message par parisse » sam. mars 11, 2017 5:43 pm

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.

parisse
Messages : 5084
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: segfaults on several non-x86 architectures

Message par parisse » mer. mars 15, 2017 9:38 am

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.

parisse
Messages : 5084
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: segfaults on several non-x86 architectures

Message par parisse » jeu. mars 16, 2017 9:58 am

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.

frederic han
Messages : 1113
Inscription : dim. mai 20, 2007 7:09 am
Localisation : Paris
Contact :

Re: segfaults on several non-x86 architectures

Message par frederic han » lun. mars 20, 2017 9:13 am

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.

parisse
Messages : 5084
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: segfaults on several non-x86 architectures

Message par parisse » lun. mars 20, 2017 9:34 am

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.

frederic han
Messages : 1113
Inscription : dim. mai 20, 2007 7:09 am
Localisation : Paris
Contact :

Re: segfaults on several non-x86 architectures

Message par frederic han » ven. mars 24, 2017 10:38 am

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...

infinity0
Messages : 36
Inscription : dim. févr. 05, 2017 5:46 pm

Re: segfaults on several non-x86 architectures

Message par infinity0 » dim. mai 28, 2017 8:01 am

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.

infinity0
Messages : 36
Inscription : dim. févr. 05, 2017 5:46 pm

Re: segfaults on several non-x86 architectures

Message par infinity0 » dim. mai 28, 2017 8:07 am

Most portable is probably to check sizeof(void*) == 4 or 8 rather than the architecture specifically.

parisse
Messages : 5084
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: segfaults on several non-x86 architectures

Message par parisse » dim. mai 28, 2017 2:02 pm

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.

parisse
Messages : 5084
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: segfaults on several non-x86 architectures

Message par parisse » mar. mai 30, 2017 11:46 am

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.

infinity0
Messages : 36
Inscription : dim. févr. 05, 2017 5:46 pm

Re: segfaults on several non-x86 architectures

Message par infinity0 » sam. juin 24, 2017 1:42 pm

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.)

Répondre