Opened 10 years ago

Closed 10 years ago

Last modified 6 years ago

#12158 closed defect (fixed)

Segfault in PARI's err_init() during pari_init_opts()

Reported by: vbraun Owned by: was
Priority: major Milestone: sage-4.8
Component: interfaces Keywords: segmentation fault pari sd35
Cc: jdemeyer Merged in: sage-4.8.alpha5
Authors: Jeroen Demeyer Reviewers: Volker Braun
Report Upstream: Reported upstream. Little or no feedback. Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by chapoton)

This segfault is on Ubuntu oneiric 11.10 32-bit with user authentication over LDAP:

vbraun@tesla:~/tesla/sage-4.8.alpha4$ ./sage -gdb
----------------------------------------------------------------------
| Sage Version 4.8.alpha4, Release Date: 2011-12-13                  |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
**********************************************************************
*                                                                    *
* Warning: this is a prerelease version, and it may be unstable.     *
*                                                                    *
**********************************************************************
/home/vbraun/tesla/sage-4.8.alpha4/local/bin/sage-ipython
GNU gdb (Ubuntu/Linaro 7.3-0ubuntu2) 7.3-2011.08
Copyright (C) 2011 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 "i686-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /home/vbraun/tesla/sage-4.8.alpha4/local/bin/python...done.
[Thread debugging using libthread_db enabled]
Python 2.6.4 (r264:75706, Dec 13 2011, 18:01:47) 
[GCC 4.6.1] on linux3
Type "help", "copyright", "credits" or "license" for more information.

Program received signal SIGSEGV, Segmentation fault.
0xb73339c2 in err_init () at ../src/language/init.c:910
910 ../src/language/init.c: No such file or directory.
 in ../src/language/init.c
(gdb) bt
#0  0xb73339c2 in err_init () at ../src/language/init.c:910
#1  pari_warn (numerr=0) at ../src/language/init.c:934
#2  0xb7323daf in pari_get_homedir (user=0xb73e0db4 "") at ../src/language/es.c:3413
#3  pari_get_homedir (user=0xb73e0db4 "") at ../src/language/es.c:3389
#4  0xb7323efe in _path_expand (s=0x81a5353 "") at ../src/language/es.c:3499
#5  path_expand (s=0x81a5352 "~") at ../src/language/es.c:3579
#6  0xb7324868 in gp_expand_path (p=0xb745d05c) at ../src/language/es.c:3642
#7  0xb7335678 in pari_init_opts (parisize=10000, maxprime=500000, init_opts=5)
    at ../src/language/init.c:734
#8  0xb65443d9 in __pyx_pf_4sage_4libs_4pari_3gen_12PariInstance___init__ (__pyx_v_self=0x867e72c, 
    __pyx_args=0x868922c, __pyx_kwds=0x0) at sage/libs/pari/gen.c:41808
#9  0xb7ed13aa in type_call (type=<optimized out>, args=0x868922c, kwds=0x0) at Objects/typeobject.c:747
#10 0xb7e78414 in PyObject_Call (func=0xb65a03c0, arg=0x868922c, kw=0x0) at Objects/abstract.c:2492
#11 0xb6552514 in initgen () at sage/libs/pari/gen.c:51753
#12 0xb7f2e50c in _PyImport_LoadDynamicModule (name=0xbffe2a38 "sage.libs.pari.gen", 
    pathname=0xbffe19ab "/home/vbraun/tesla/sage-4.8.alpha4/local/lib/python2.6/site-packages/sage/libs/pari/gen.so", fp=0x8655798) at ./Python/importdl.c:53
#13 0xb7f2bf50 in load_module (name=0xbffe2a38 "sage.libs.pari.gen", fp=<optimized out>, 
    buf=0xbffe19ab "/home/vbraun/tesla/sage-4.8.alpha4/local/lib/python2.6/site-packages/sage/libs/pari/gen.so", type=3, loader=0x0) at Python/import.c:1828
#14 0xb7f2c629 in import_submodule (mod=0x860d674, subname=0xbffe2a47 "gen", 
    fullname=0xbffe2a38 "sage.libs.pari.gen") at Python/import.c:2589
#15 0xb7f2c8a9 in load_next (mod=0x860d674, altmod=0xb7fb64ac, p_name=0xbffe2a2c, 
    buf=0xbffe2a38 "sage.libs.pari.gen", p_buflen=0xbffe2a34) at Python/import.c:2409
#16 0xb7f2ce96 in import_module_level (name=0x0, globals=<optimized out>, fromlist=0xb7fb64ac, level=-1, 
    locals=<optimized out>) at Python/import.c:2131
#17 0xb7f2d457 in PyImport_ImportModuleLevel (name=0x8502754 "gen", globals=0x8682dfc, locals=0x8682dfc, 
    fromlist=0xb7fb64ac, level=-1) at Python/import.c:2182

Really, there are two bugs at the same time:

  1. Sage's gnutls library conflicts with the system gnutls library, which breaks LDAP. Now as soon as LD_LIBRARY_PATH includes the new gnutls, user account information can no longer be retrieved. For example:
    vbraun@tesla:~$ whoami
    vbraun
    
    but
    vbraun@tesla:~$ sage -sh
    
    Starting subshell with Sage environment variables set.
    Be sure to exit when you are done and do not do anything
    with other copies of Sage!
    
    Bypassing shell configuration files ...
    
    SAGE_ROOT=/home/vbraun/tesla/sage-4.8.alpha4
    (sage subshell) tesla:~ I have no name!$ whoami
    whoami: cannot find name for user ID 12050
    
  2. Now that Pari is unable to find the home directory, it tries to print a warning. This succeeds if I just run the stand-alone pari with sage -gp:
    vbraun@tesla:~$ sage -gp
      ***   Warning: can't expand ~.
      ***   Warning: can't expand ~.
                             GP/PARI CALCULATOR Version 2.5.0 (development svn-13228)
                            i686 running linux (ix86/GMP-5.0.1 kernel) 32-bit version
                         compiled: Dec 13 2011, gcc-4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3) 
                                  (readline v6.2 enabled, extended help enabled)
    
    but Sage does not handle the pari error correctly and segfaults unnecessarily.

Upstream: http://pari.math.u-bordeaux.fr/cgi-bin/bugreport.cgi?bug=1264

spkg: http://boxen.math.washington.edu/home/jdemeyer/spkg/pari-2.5.0.p3.spkg


A workaround is to delete Sage's gnutls libraries, that is

rm sage-4.8.alpha4/local/lib/libgnutls*

after Sage has finished compiling.

Attachments (1)

pari-2.5.0.p2-p3.diff (1.7 KB) - added by jdemeyer 10 years ago.
Diff for the pari spkg, for review only

Download all attachments as: .zip

Change History (13)

comment:1 Changed 10 years ago by jdemeyer

  • Component changed from build to interfaces
  • Keywords segmentation fault pari added
  • Owner changed from GeorgSWeber to was
  • Summary changed from Segfault in err_init to Segfault in PARI's err_init during pari_init_opts()

comment:2 Changed 10 years ago by vbraun

It seems our options are

  1. add yet another if/then clause to the gnutls spkg to kludge over this
  2. switch from LD_LIBRARY_PATH to setting rpaths with the compilerwrapper

comment:3 Changed 10 years ago by jdemeyer

  1. add a workaround to the PARI error/warning handling (which is probably doable).

comment:4 Changed 10 years ago by vbraun

We should certainly fix 3., but that just prevents the segfault when trying to print a warning and not the underlying problem.

comment:5 Changed 10 years ago by jdemeyer

Volker, could you please test whether this spkg fixes 3. If it does, I will make this into a proper spkg: http://boxen.math.washington.edu/home/jdemeyer/spkg/pari-2.5.0.p3.spkg

comment:6 Changed 10 years ago by vbraun

Fixes it! With the new pari spkg, Sage prints

  ***   Warning: can't expand ~.
  ***   Warning: can't expand ~.

before segfaulting due to #12157.

comment:7 Changed 10 years ago by jdemeyer

  • Authors set to Jeroen Demeyer
  • Report Upstream changed from N/A to Not yet reported upstream; Will do shortly.

comment:8 Changed 10 years ago by jdemeyer

  • Keywords sd35 added
  • Summary changed from Segfault in PARI's err_init during pari_init_opts() to Segfault in PARI's err_init() during pari_init_opts()

comment:9 Changed 10 years ago by jdemeyer

  • Description modified (diff)
  • Report Upstream changed from Not yet reported upstream; Will do shortly. to Reported upstream. Little or no feedback.
  • Reviewers set to Volker Braun
  • Status changed from new to needs_review

Changed 10 years ago by jdemeyer

Diff for the pari spkg, for review only

comment:10 Changed 10 years ago by vbraun

  • Status changed from needs_review to positive_review

Nice.

comment:11 Changed 10 years ago by jdemeyer

  • Merged in set to sage-4.8.alpha5
  • Resolution set to fixed
  • Status changed from positive_review to closed

comment:12 Changed 6 years ago by chapoton

  • Description modified (diff)
Note: See TracTickets for help on using tickets.