Bug 246049 - math/giacxcas: libgiac.so causes segfault when mixed with other libs
Summary: math/giacxcas: libgiac.so causes segfault when mixed with other libs
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Thierry Thomas
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-30 11:08 UTC by Thierry Thomas
Modified: 2020-05-15 10:20 UTC (History)
0 users

See Also:
yuri: maintainer-feedback+


Attachments
Test case to reproduce the error: conftest.c (253 bytes, text/plain)
2020-04-30 11:08 UTC, Thierry Thomas
no flags Details
Various fixes for math/giacxcas (3.04 KB, patch)
2020-05-14 21:18 UTC, Thierry Thomas
no flags Details | Diff
Poudriere log. (41.19 KB, application/x-bzip)
2020-05-14 21:19 UTC, Thierry Thomas
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thierry Thomas freebsd_committer freebsd_triage 2020-04-30 11:08:51 UTC
Created attachment 213939 [details]
Test case to reproduce the error: conftest.c

math/giacxcas is built with Gcc, and a comment says:
# Warning:  don't remove the USE_GCC without a runtime test *after* make install
USE_GCC=	yes

But this causes segfault when libgiac is mixed with other libraries, e.g. libmpfi.

How to reproduce:
- take the attached conftest.c and compile it with or without linking with -lgiac
- both build fine
- run the resulting conftest: the one linked with -lgiac will segfaut.

E.g. on FreeBSD-12.1 / amd64:

$ cc -o conftest conftest.c -isystem /usr/local/include -Wl,-rpath=/usr/local/lib/gcc9 -L/usr/local/lib/gcc9 -B/usr/local/bin -L/usr/local/lib -lgmp -lmpfr -lmpfi -lflint
$ ./conftest
1.5.4

$ cc -o conftest conftest.c -isystem /usr/local/include -Wl,-rpath=/usr/local/lib/gcc9 -L/usr/local/lib/gcc9 -B/usr/local/bin -L/usr/local/lib -lgiac -lgmp -lmpfr -lmpfi -lflint
$ ./conftest
zsh: segmentation fault (core dumped)  ./conftest
$ lldb ./conftest
(lldb) target create "./conftest"
Current executable set to './conftest' (x86_64).
(lldb) b main
Breakpoint 1: where = conftest`main + 15 at conftest.c:6:3, address = 0x00000000004007cf
(lldb) r
Process 54933 launching
Process 54933 launched: '/usr/ports/math/sage/work/sage-9.1.rc1/conftest' (x86_64)
Process 54933 stopped
* thread #1, name = 'conftest', stop reason = signal SIGSEGV: address access protected (fault address: 0x803d72a18)
    frame #0: 0x0000000803d72a18
->  0x803d72a18: xorb   %cl, %cl
    0x803d72a1a: rep    addb    $0x8, %al
    0x803d72a1d: addb   %al, (%rax)
    0x803d72a1f: addb   %al, (%rax)
Comment 1 Thierry Thomas freebsd_committer freebsd_triage 2020-05-14 21:18:41 UTC
Created attachment 214503 [details]
Various fixes for math/giacxcas

The attached patch fixes the reported problem, and also brings several
other fixes and improvments for math/giacxcas:

- do not link cocoalib with the static libgmp (other binaries are linked
  against the dynamic one)
- fixes Fl::set_fonts for some badly registered fonts
- remove USE_GCC: a runtime has been done and it seems OK
- add USES=localbase to simplify the flags
- add 2 missing libraries (libecm and libmpf): unless explicitely
  disabled they are used
- Makefiles have been patched to install the in-line docs under
  $docdir => make programs and files coherent with that
- add a TEST_TARGET: all tests but 2 pass
- add USE_PERL5=run, because pgiac is a Perl script
Comment 2 Thierry Thomas freebsd_committer freebsd_triage 2020-05-14 21:19:38 UTC
Created attachment 214504 [details]
Poudriere log.
Comment 3 Yuri Victorovich freebsd_committer freebsd_triage 2020-05-14 21:22:54 UTC
Sorry for the delay, Thierry.

Go ahead and commit the patch.

Thank you,
Yuri
Comment 4 Thierry Thomas freebsd_committer freebsd_triage 2020-05-15 10:19:33 UTC
Committed, thanks!
Comment 5 commit-hook freebsd_committer freebsd_triage 2020-05-15 10:20:02 UTC
A commit references this bug:

Author: thierry
Date: Fri May 15 10:19:26 UTC 2020
New revision: 535281
URL: https://svnweb.freebsd.org/changeset/ports/535281

Log:
  - Fix an initial problem encountered with libgiac: it could not be linked
    with other libraries.

  + several other fixes and improvments for math/giacxcas:

  - do not link cocoalib with the static libgmp (other binaries are linked
    against the dynamic one)
  - fixes Fl::set_fonts for some badly registered fonts
  - remove USE_GCC: a runtime has been done and it seems OK
  - add USES=localbase to simplify the flags
  - add 2 missing libraries (libecm and libmpf): unless explicitely
    disabled they are used
  - Makefiles had been patched to install the in-line docs under
    $docdir => make programs and files coherent with that
  - add a TEST_TARGET: all tests but 2 pass
  - add USE_PERL5=run, because pgiac is a Perl script.

  PR:		246049
  Submitted by:	/me
  Approved by:	yuri@ (maintainer)

Changes:
  head/math/giacxcas/Makefile