Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segfault in numerical_integral() #16788

Open
rwst opened this issue Aug 9, 2014 · 26 comments
Open

segfault in numerical_integral() #16788

rwst opened this issue Aug 9, 2014 · 26 comments

Comments

@rwst
Copy link

rwst commented Aug 9, 2014

sage: numerical_integral(sin(x^2)/(x^2), 1, infinity, max_points=10^10)
---------------------------------------------------------------------------
SignalError                               Traceback (most recent call last)
<ipython-input-7-a164db8ca706> in <module>()
----> 1 numerical_integral(sin(x**Integer(2))/(x**Integer(2)), Integer(1), infinity, max_points=Integer(10)**Integer(10))

/home/ralf/sage/local/lib/python2.7/site-packages/sage/gsl/integration.so in sage.gsl.integration.numerical_integral (build/cythonized/sage/gsl/integration.c:2626)()

/home/ralf/sage/local/lib/python2.7/site-packages/sage/ext/c_lib.so in sage.ext.c_lib.sig_raise_exception (build/cythonized/sage/ext/c_lib.c:1208)()

SignalError: Segmentation fault

Better error messages would be needed here, as well.

The segfault happens on OpenSuSE 12.3 (both 6.2 and 6.3) and SMC (Ubuntu) but not on Mac OS X 10.7

CC: @kcrisman

Component: calculus

Keywords: integral, numerics, crash

Author: Ralf Stephan

Branch/Commit: u/chapoton/16788 @ 87332f3

Reviewer: Marc Mezzarobba

Issue created by migration from https://trac.sagemath.org/ticket/16788

@rwst rwst added this to the sage-6.3 milestone Aug 9, 2014
@rwst

This comment has been minimized.

@rwst
Copy link
Author

rwst commented Aug 9, 2014

comment:2

Segfaults are always critical.

@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@kcrisman
Copy link
Member

comment:4

What platform is this on? On Mac OS X 10.7 I get (0.285725372660691, 7.519910599701474e-05) for both Sage 5.12 and 6.2.

@rwst

This comment has been minimized.

@kcrisman
Copy link
Member

comment:6

What platform is this on? On Mac OS X 10.7 I get (0.285725372660691, 7.519910599701474e-05) for both Sage 5.12 and 6.2.

This could be a good situation to ask on sage-devel; there are a wide variety of systems there and if everyone tried quickly you might get a lot of feedback. It's too bad the traceback is so short, that's not a lot of info to go on :( as usually I like tracking these things down.

On SMC, which is Ubuntu:

$ sage
┌────────────────────────────────────────────────────────────────────┐
│ Sage Version 6.3, Release Date: 2014-08-10                         │
│ Type "notebook()" for the browser-based notebook interface.        │
│ Type "help()" for help.                                            │
└────────────────────────────────────────────────────────────────────┘
sage: numerical_integral(sin(x^2)/(x^2), 1, infinity, max_points=10^10)
---------------------------------------------------------------------------
SignalError                               Traceback (most recent call last)
<ipython-input-1-a164db8ca706> in <module>()
----> 1 numerical_integral(sin(x**Integer(2))/(x**Integer(2)), Integer(1), infinity, max_points=Integer(10)**Integer(10))
 
/usr/local/sage/sage-6.3.beta6/local/lib/python2.7/site-packages/sage/gsl/integration.so in sage.gsl.integration.numerical_integral (build/cythonized/sage/gsl/integration.c:2626)
()
 
/usr/local/sage/sage-6.3.beta6/local/lib/python2.7/site-packages/sage/ext/c_lib.so in sage.ext.c_lib.sig_raise_exception (build/cythonized/sage/ext/c_lib.c:1208)()
 
SignalError: Segmentation fault
sage: 
Exiting Sage (CPU time 0m0.30s, Wall time 0m7.00s).
~$ uname -a
Linux compute20dc0 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Does yours only happen with Sage 6.3? I don't have that yet locally, though on 6.3.beta5 all is still well.

@rwst

This comment has been minimized.

@rwst
Copy link
Author

rwst commented Nov 6, 2014

comment:8

It still happens in 6.4rc1. Changing a,b does not matter, so all functions gsl_integration_qag* are affected but not the qng method:

sage: integrate(sin(x^2)/(x^2), 1, infinity).n()
0.285736646322853
sage: numerical_integral(sin(x^2)/(x^2), 1,infinity, max_points=10^10, algorithm='qng')
(nan, nan)

@rwst
Copy link
Author

rwst commented Nov 6, 2014

comment:9

OK, the reason is, gsl_integration_workspace_alloc returns NULL which is then fed into the qag integration. So, the code needs to catch it and give an error message.

@rwst
Copy link
Author

rwst commented Nov 6, 2014

@rwst
Copy link
Author

rwst commented Nov 6, 2014

Author: Ralf Stephan

@rwst
Copy link
Author

rwst commented Nov 6, 2014

Commit: af3158a

@rwst
Copy link
Author

rwst commented Nov 6, 2014

New commits:

af3158a16788: catch gsl error and tell the user about it

@jdemeyer
Copy link

jdemeyer commented Nov 7, 2014

comment:12

should be MemoryError.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 7, 2014

Branch pushed to git repo; I updated commit sha1. New commits:

c2bdcba16788: fix exception type

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 7, 2014

Changed commit from af3158a to c2bdcba

@jdemeyer
Copy link

jdemeyer commented Nov 7, 2014

comment:16

Needs testing on 32-bit.

@fchapoton
Copy link
Contributor

Changed commit from c2bdcba to 87332f3

@fchapoton
Copy link
Contributor

comment:17

let us try again..


New commits:

87332f3trac 16788 catch a memory allocation error

@fchapoton
Copy link
Contributor

Changed branch from u/rws/segfault_in_numerical_integral__ to u/chapoton/16788

@fchapoton
Copy link
Contributor

comment:18

ping ?

@fchapoton fchapoton modified the milestones: sage-8.2, sage-8.3 Jun 7, 2018
@mezzarobba
Copy link
Member

Reviewer: Marc Mezzarobba

@vbraun
Copy link
Member

vbraun commented Jun 10, 2018

comment:21

On OSX:

**********************************************************************
File "src/sage/calculus/integration.pyx", line 237, in sage.calculus.integration.?
Failed example:
    numerical_integral(sin(x^2)/(x^2), 1,infinity, max_points=10^10)
Expected:
    Traceback (most recent call last):
    ...
    MemoryError: could not allocate workspace: max_points too big
Got:
    (0.285725372660691, 7.519910599701474e-05)

@vbraun
Copy link
Member

vbraun commented Jun 11, 2018

comment:23

Fails on 32-bit, too

@rwst
Copy link
Author

rwst commented Jun 11, 2018

comment:24

Well 10^10 > 2^32 so it may have been an int size problem from the start...

@vbraun
Copy link
Member

vbraun commented Jun 11, 2018

comment:25

The OSX box is 64-bit

@videlec
Copy link
Contributor

videlec commented Aug 3, 2018

comment:26

update milestone 8.3 -> 8.4

@videlec videlec modified the milestones: sage-8.3, sage-8.4 Aug 3, 2018
@mkoeppe mkoeppe removed this from the sage-8.4 milestone Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants