Opened 6 years ago

Last modified 12 months ago

#14677 new defect

Limit computation causes Sage to crash

Reported by: tmonteil Owned by: burcin
Priority: critical Milestone: sage-wishlist
Component: symbolics Keywords: maxima, limit, segfault
Cc: kcrisman, slelievre Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by slelievre)

The following behaviour has been reported on ask.sagemath.org:

sage: f(x) = (x^x-sin(x)^sin(x))/(x^3*log(x))
sage: f(x).limit(x=0)

leads to

;;;
;;; Detected access to protected memory, also kwown as 'bus or segmentation fault'.
;;; Jumping to the outermost toplevel prompt
;;;

/opt/sagemath/sage/sage : ligne 135 :  7856 Erreur de segmentation  "$SAGE_ROOT/spkg/bin/sage" "$@"

This still happens on sage-5.0, but on sage-4.8, this leads to

und

Note: a similar problem is reported at #26497.

Change History (15)

comment:1 Changed 6 years ago by ppurka

happens on 5.10rc0 too.

comment:2 Changed 6 years ago by leif

... and of course Maxima (and probably also ECL) is to blame.

Similar issues were reported on the ticket dealing with the last Maxima upgrade IIRC.

comment:3 Changed 6 years ago by kcrisman

  • Cc kcrisman added

comment:4 Changed 6 years ago by vbraun

Infinite recursion in ECL:

sage: sage: f(x)=(x^x-sin(x)^sin(x))/(x^3*log(x))
sage: sage: f(x).limit(x=0) 

Program received signal SIGSEGV, Segmentation fault.
ecl_bds_unwind (env=env@entry=0x7ffff7c0e000, new_bds_top_index=<optimized out>)
    at /home/vbraun/opt/sage-5.10.rc0/spkg/build/ecl-12.12.1.p3/src/src/c/stacks.d:173
173	/home/vbraun/opt/sage-5.10.rc0/spkg/build/ecl-12.12.1.p3/src/src/c/stacks.d: No such file or directory.
Missing separate debuginfos, use: debuginfo-install expat-2.1.0-4.fc18.x86_64 fontconfig-2.10.2-2.fc18.x86_64 glibc-2.16-31.fc18.x86_64 libgcc-4.7.2-8.fc18.x86_64 libstdc++-4.7.2-8.fc18.x86_64 ncurses-libs-5.9-10.20130413.fc18.x86_64
(gdb) bt
#0  ecl_bds_unwind (env=env@entry=0x7ffff7c0e000, new_bds_top_index=<optimized out>)
    at /home/vbraun/opt/sage-5.10.rc0/spkg/build/ecl-12.12.1.p3/src/src/c/stacks.d:173
#1  0x00007fffbcf62dcc in ecl_unwind (env=0x7ffff7c0e000, fr=<optimized out>)
    at /home/vbraun/opt/sage-5.10.rc0/spkg/build/ecl-12.12.1.p3/src/src/c/stacks.d:531
#2  0x00007fffbcf61096 in cl_go (tag_id=<optimized out>, label=<optimized out>)
    at /home/vbraun/opt/sage-5.10.rc0/spkg/build/ecl-12.12.1.p3/src/src/c/cmpaux.d:162
#3  0x00007fffbcf1f7f1 in ecl_interpret (frame=frame@entry=0x7fffffe9e1c0, env=<optimized out>, 
    bytecodes=0x5deb690)
    at /home/vbraun/opt/sage-5.10.rc0/spkg/build/ecl-12.12.1.p3/src/src/c/interpreter.d:753
#4  0x00007fffbcf1ff93 in _ecl_bclosure_dispatch_vararg (narg=<optimized out>)
    at /home/vbraun/opt/sage-5.10.rc0/spkg/build/ecl-12.12.1.p3/src/src/c/interpreter.d:204
#5  0x00007fffbcee8eb1 in L25signal (narg=narg@entry=113736945, V1=<optimized out>) at clos/conditions.c:1419
#6  0x00007fffbcee999c in L76universal_error_handler (V1=0x7ffff7c0e000, V2=0x5a50240, V3=0x6c77d41)
    at clos/conditions.c:2884
#7  0x00007fffbcf1d4f0 in cl_funcall (narg=<optimized out>, narg@entry=4, function=<optimized out>)
    at /home/vbraun/opt/sage-5.10.rc0/spkg/build/ecl-12.12.1.p3/src/src/c/eval.d:132
#8  0x00007fffbcf3b759 in cl_cerror (narg=narg@entry=6, cformat=0x688b900, eformat=
    0x7fffbd219040 <cl_symbols+79872>)
    at /home/vbraun/opt/sage-5.10.rc0/spkg/build/ecl-12.12.1.p3/src/src/c/error.d:540
#9  0x00007fffbcf6277b in ecl_bds_overflow ()
    at /home/vbraun/opt/sage-5.10.rc0/spkg/build/ecl-12.12.1.p3/src/src/c/stacks.d:157
#10 0x00007fffbcf39a60 in ecl_bds_bind_inl (v=0x1, s=<optimized out>, env=0x7ffff7c0e000) at ../ecl/stacks.h:84
#11 ecl_princ (obj=0x7, strm=strm@entry=0x6470140)
    at /home/vbraun/opt/sage-5.10.rc0/spkg/build/ecl-12.12.1.p3/src/src/c/print.d:322
#12 0x00007fffbcea8577 in LC24__g283 (V1=0x6470140, V2=<optimized out>, V3=0x1, V4=<optimized out>, V5=0x1)
    at lsp/format.c:2081
#13 0x00007fffbceae0e0 in L8interpret_directive_list (V1=0x6470140, V2=<optimized out>, V3=0x6c77df1, V4=
    0x6c77df1) at lsp/format.c:863
#14 0x00007fffbceb8052 in L7formatter_aux (narg=narg@entry=3, V1=V1@entry=0x6470140, V2=V2@entry=0x5cd6de0, V3=
    0x0) at lsp/format.c:819
#15 0x00007fffbcf68e3f in cl_format (narg=narg@entry=3, strm=0x6470140, strm@entry=0x1, string=0x5cd6de0)
    at /home/vbraun/opt/sage-5.10.rc0/spkg/build/ecl-12.12.1.p3/src/src/c/format.d:2232
#16 0x00007fffbc0da2d2 in L27exploden (V1=0x7) at binary-ecl/commac.c:1049
#17 0x00007fffbc432aed in L15msize_atom (V1=<optimized out>, V2=<optimized out>, V3=0x1)
    at binary-ecl/grind.c:772
#18 0x00007fffbc42f04b in L14msize (V1=0x7, V2=0x6c77e11, V3=0x1, V4=<optimized out>, V5=<optimized out>)
    at binary-ecl/grind.c:694
#19 0x00007fffbc42d9c7 in L23msize_infix (V1=0x6c77e41, V2=<optimized out>, V3=0x6c77e01)
    at binary-ecl/grind.c:1132
#20 0x00007fffbc42f04b in L14msize (V1=0x6c77e41, V2=0x6c77e11, V3=0x6c77e01, V4=<optimized out>, 
    V5=<optimized out>) at binary-ecl/grind.c:694
#21 0x00007fffbc42f77f in L18msize_paren (V1=0x6c77e41, V2=0x6c77e71, V3=<optimized out>)
    at binary-ecl/grind.c:907
#22 0x00007fffbc42f04b in L14msize (V1=0x6c77e41, V2=0x6c77e71, V3=0x6c76041, V4=<optimized out>, 
    V5=<optimized out>) at binary-ecl/grind.c:694
#23 0x00007fffbc42da73 in L23msize_infix (V1=<optimized out>, V2=<optimized out>, V3=0x6c76041)
    at binary-ecl/grind.c:1138
#24 0x00007fffbc42f04b in L14msize (V1=0x6c77fd1, V2=0x6c77f61, V3=0x6c76041, V4=<optimized out>, 
    V5=<optimized out>) at binary-ecl/grind.c:694
#25 0x00007fffbc42df79 in L39msize_mminus (V1=<optimized out>, V2=<optimized out>, V3=0x6c76041)
    at binary-ecl/grind.c:1772
#26 0x00007fffbc42f04b in L14msize (V1=0x6c77fa1, V2=0x1, V3=0x6c76041, V4=<optimized out>, V5=<optimized out>)
    at binary-ecl/grind.c:694
#27 0x00007fffbc4308c5 in L21msize_list (V1=<optimized out>, V2=<optimized out>, V3=0x6c76041)
    at binary-ecl/grind.c:1076
#28 0x00007fffbc43194d in L20msize_function (V1=<optimized out>, V2=<optimized out>, V3=0x1, 
    V4=<optimized out>) at binary-ecl/grind.c:1019
#29 0x00007fffbc42f2d8 in L14msize (V1=0x6c768a1, V2=0x1, V3=0x1, V4=<optimized out>, V5=<optimized out>)
    at binary-ecl/grind.c:700
#30 0x00007fffbc42c5b2 in L12mstring (V1=0x6c768a1) at binary-ecl/grind.c:585
#31 0x00007fffbc102b1b in L7aformat (narg=narg@entry=3) at binary-ecl/mformt.c:753
#32 0x00007fffbc35a807 in L49gensym_readable (V1=0x6c768a1) at binary-ecl/rat3e.c:2548
#33 0x00007fffbc35a600 in L50orderpointer (V1=<optimized out>) at binary-ecl/rat3e.c:2613
#34 0x00007fffbc4cb8d6 in L141taylor1 (V1=0x6c767a1, V2=0x6c762c1) at binary-ecl/hayat.c:8729
#35 0x00007fffbc4d3f9c in L132taylor_ (V1=<optimized out>, V2=0x6c763e1) at binary-ecl/hayat.c:8104
#36 0x00007fffbc4ccd26 in L131_taylor (narg=narg@entry=4, V1=V1@entry=0x6c767a1) at binary-ecl/hayat.c:8073
#37 0x00007fffbc560ba9 in L189calculate_series (V1=0x6c767a1, V2=0x688bae0) at binary-ecl/limit.c:13286
#38 0x00007fffbc5884da in L185mrv_leadterm (V1=0x6c75bd1, V2=0x5f46510, V3=<optimized out>)
    at binary-ecl/limit.c:13133
#39 0x00007fffbc5883cc in L185mrv_leadterm (V1=0x6c747d1, V2=0x5f46510, V3=0x6c741f1)
    at binary-ecl/limit.c:13110
#40 0x00007fffbc56a9fe in L191limitinf (V1=0x6c747d1, V2=0x5f46510) at binary-ecl/limit.c:13390
#41 0x00007fffbc561e58 in L180mrv (V1=0x6a87f31, V2=0x5f46510) at binary-ecl/limit.c:12729
#42 0x00007fffbc561d13 in L180mrv (V1=0x6c74841, V2=0x5f46510) at binary-ecl/limit.c:12704
---Type <return> to continue, or q <return> to quit---
#43 0x00007fffbc588676 in L185mrv_leadterm (V1=0x6c74841, V2=0x5f46510, V3=<optimized out>)
    at binary-ecl/limit.c:13099
#44 0x00007fffbc56a9fe in L191limitinf (V1=0x6c74841, V2=0x5f46510) at binary-ecl/limit.c:13390
#45 0x00007fffbc56acf4 in L182mrv_compare (V1=0x6a87f31, V2=<optimized out>, V3=0x5f46510)
    at binary-ecl/limit.c:12850
#46 0x00007fffbc5631d2 in L181mrv_max (V1=0x6c72ce1, V2=0x6c72b41, V3=0x5f46510) at binary-ecl/limit.c:12812
#47 0x00007fffbc561d13 in L180mrv (V1=0x6c5dc71, V2=0x5f46510) at binary-ecl/limit.c:12704
#48 0x00007fffbc588676 in L185mrv_leadterm (V1=0x6c5dc71, V2=0x5f46510, V3=<optimized out>)
    at binary-ecl/limit.c:13099
#49 0x00007fffbc56a9fe in L191limitinf (V1=0x6c5dc71, V2=0x5f46510) at binary-ecl/limit.c:13390
#50 0x00007fffbc56acf4 in L182mrv_compare (V1=0x6a87f31, V2=<optimized out>, V3=0x5f46510)
    at binary-ecl/limit.c:12850
#51 0x00007fffbc5631d2 in L181mrv_max (V1=0x6c5cfe1, V2=0x6c5ce81, V3=0x5f46510) at binary-ecl/limit.c:12812
#52 0x00007fffbc561d13 in L180mrv (V1=0x6c3f9d1, V2=0x5f46510) at binary-ecl/limit.c:12704
#53 0x00007fffbc588676 in L185mrv_leadterm (V1=0x6c3f9d1, V2=0x5f46510, V3=<optimized out>)
    at binary-ecl/limit.c:13099
#54 0x00007fffbc56a9fe in L191limitinf (V1=0x6c3f9d1, V2=0x5f46510) at binary-ecl/limit.c:13390
#55 0x00007fffbc56acf4 in L182mrv_compare (V1=0x6a87f31, V2=<optimized out>, V3=0x5f46510)
    at binary-ecl/limit.c:12850
#56 0x00007fffbc5631d2 in L181mrv_max (V1=0x6c3d241, V2=0x6c3d041, V3=0x5f46510) at binary-ecl/limit.c:12812
#57 0x00007fffbc561d13 in L180mrv (V1=0x6c20101, V2=0x5f46510) at binary-ecl/limit.c:12704
#58 0x00007fffbc588676 in L185mrv_leadterm (V1=0x6c20101, V2=0x5f46510, V3=<optimized out>)
    at binary-ecl/limit.c:13099
#59 0x00007fffbc56a9fe in L191limitinf (V1=0x6c20101, V2=0x5f46510) at binary-ecl/limit.c:13390
#60 0x00007fffbc56acf4 in L182mrv_compare (V1=0x6a87f31, V2=<optimized out>, V3=0x5f46510)
    at binary-ecl/limit.c:12850
#61 0x00007fffbc5631d2 in L181mrv_max (V1=0x6c1fd61, V2=0x6c1fb31, V3=0x5f46510) at binary-ecl/limit.c:12812
#62 0x00007fffbc561d13 in L180mrv (V1=0x6c01a81, V2=0x5f46510) at binary-ecl/limit.c:12704
#63 0x00007fffbc588676 in L185mrv_leadterm (V1=0x6c01a81, V2=0x5f46510, V3=<optimized out>)
    at binary-ecl/limit.c:13099
#64 0x00007fffbc56a9fe in L191limitinf (V1=0x6c01a81, V2=0x5f46510) at binary-ecl/limit.c:13390
#65 0x00007fffbc56acf4 in L182mrv_compare (V1=0x6a87f31, V2=<optimized out>, V3=0x5f46510)
    at binary-ecl/limit.c:12850
#66 0x00007fffbc5631d2 in L181mrv_max (V1=0x6d63d31, V2=0x6d63be1, V3=0x5f46510) at binary-ecl/limit.c:12812
#67 0x00007fffbc561d13 in L180mrv (V1=0x53c7811, V2=0x5f46510) at binary-ecl/limit.c:12704
#68 0x00007fffbc588676 in L185mrv_leadterm (V1=0x53c7811, V2=0x5f46510, V3=<optimized out>)
    at binary-ecl/limit.c:13099
#69 0x00007fffbc56a9fe in L191limitinf (V1=0x53c7811, V2=0x5f46510) at binary-ecl/limit.c:13390
#70 0x00007fffbc56acf4 in L182mrv_compare (V1=0x6a87f31, V2=<optimized out>, V3=0x5f46510)
    at binary-ecl/limit.c:12850
#71 0x00007fffbc5631d2 in L181mrv_max (V1=0x53c6b81, V2=0x53c69f1, V3=0x5f46510) at binary-ecl/limit.c:12812
#72 0x00007fffbc561d13 in L180mrv (V1=0x5b64101, V2=0x5f46510) at binary-ecl/limit.c:12704
#73 0x00007fffbc588676 in L185mrv_leadterm (V1=0x5b64101, V2=0x5f46510, V3=<optimized out>)
    at binary-ecl/limit.c:13099
#74 0x00007fffbc56a9fe in L191limitinf (V1=0x5b64101, V2=0x5f46510) at binary-ecl/limit.c:13390
#75 0x00007fffbc56acf4 in L182mrv_compare (V1=0x6a87f31, V2=<optimized out>, V3=0x5f46510)
    at binary-ecl/limit.c:12850
#76 0x00007fffbc5631d2 in L181mrv_max (V1=0x5b61341, V2=0x5b61041, V3=0x5f46510) at binary-ecl/limit.c:12812
#77 0x00007fffbc561d13 in L180mrv (V1=0x5aea891, V2=0x5f46510) at binary-ecl/limit.c:12704
#78 0x00007fffbc588676 in L185mrv_leadterm (V1=0x5aea891, V2=0x5f46510, V3=<optimized out>)
    at binary-ecl/limit.c:13099
#79 0x00007fffbc56a9fe in L191limitinf (V1=0x5aea891, V2=0x5f46510) at binary-ecl/limit.c:13390
#80 0x00007fffbc56acf4 in L182mrv_compare (V1=0x6a87f31, V2=<optimized out>, V3=0x5f46510)
    at binary-ecl/limit.c:12850
#81 0x00007fffbc5631d2 in L181mrv_max (V1=0x5adbae1, V2=0x5adb7d1, V3=0x5f46510) at binary-ecl/limit.c:12812
#82 0x00007fffbc561d13 in L180mrv (V1=0x5fe9951, V2=0x5f46510) at binary-ecl/limit.c:12704
#83 0x00007fffbc588676 in L185mrv_leadterm (V1=0x5fe9951, V2=0x5f46510, V3=<optimized out>)
    at binary-ecl/limit.c:13099
... thousands of repetitions ...

comment:5 Changed 6 years ago by jdemeyer

Fixed by #13973.

comment:6 Changed 6 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:7 Changed 6 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:8 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:9 Changed 5 years ago by pbruin

Unfortunately not fixed by #13973, despite comment:5. The crash appears to be related to the domain: complex setting used by Sage. GDB shows that it is still the same infinite recursion as in comment:4. This is possibly caused by the fact that Maxima uses Gruntz's algorithm, which was designed only for real functions.

With a patched Sage version of Maxima (5.33.0.p1, see #15033) using ECL:

(%i1) f: (x^x-sin(x)^sin(x))/(x^3*log(x));
                                x         sin(x)
                               x  - sin(x)
(%o1)                          -----------------
                                    3
                                   x  log(x)
(%i2) limit(f, x, 0);
(%o2)                                 und
(%i3) domain: complex;
(%o3)                               complex
(%i4) limit(f, x, 0);

Maxima encountered a Lisp error:

 BINDING-STACK overflow at size 10240. Stack can probably be resized.

Automatically continuing.
To enable the Lisp debugger set *debugger-hook* to nil.
Maxima encountered a Lisp error:

 Detected access to an invalid or protected memory address.

Automatically continuing.
To enable the Lisp debugger set *debugger-hook* to nil.

;;;
;;; Detected access to protected memory, also kwown as 'bus or segmentation fault'.
;;; Jumping to the outermost toplevel prompt
;;;

(repeated many times, then a core dump).

Just for comparison, in a recent development version of Maxima (after 5.33.0) using GCL:

(%i4) limit(f, x, 0);

(no error message, the answer is an empty line). Finally, using SBCL:

(%i4) limit(f, x, 0);
INFO: Binding stack guard page unprotected
Binding stack guard page temporarily disabled: proceed with caution
INFO: Binding stack guard page reprotected

(just once, then returns to prompt).

comment:10 Changed 5 years ago by pbruin

One can avoid the crash by taking the limit for x -> 0 from above, but then the value of the limit is wrong, again due to the domain: complex setting:

sage: f(x) = (x^x - sin(x)^sin(x))/(x^3*log(x))
sage: f.limit(x=0, dir='plus')
x |--> -Infinity
sage: sage.calculus.calculus.maxima('domain: real')
real
sage: f.limit(x=0, dir='plus')
x |--> 1/6

Plotting the function [edit: or reading the ask.sagemath.org question linked to above] suggests that 1/6 is the correct value.

Last edited 5 years ago by pbruin (previous) (diff)

comment:11 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:12 Changed 5 years ago by rws

  • Priority changed from major to critical

comment:13 Changed 5 years ago by leif

  • Milestone changed from sage-6.4 to sage-6.5

... at least. (We're currently at 6.5.rc0; 6.4 has been released a while ago.)

comment:14 Changed 5 years ago by leif

  • Milestone changed from sage-6.5 to sage-6.6

comment:15 Changed 12 months ago by slelievre

  • Cc slelievre added
  • Description modified (diff)
  • Keywords limit segfault added
  • Milestone changed from sage-6.6 to sage-wishlist

Note: a similar problem is reported at #26497.

Note: See TracTickets for help on using tickets.