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

GP interface confused by stack overflow when enlarging results vector #15446

Closed
pjbruin opened this issue Nov 22, 2013 · 12 comments
Closed

GP interface confused by stack overflow when enlarging results vector #15446

pjbruin opened this issue Nov 22, 2013 · 12 comments

Comments

@pjbruin
Copy link
Contributor

pjbruin commented Nov 22, 2013

From Georgi Guninski on sage-support (https://groups.google.com/forum/#!topic/sage-support/A_GilhiUAwM):

sage: gp("{T(n)=n+1}")
sage: for n in [ 1 .. 2**20]:
    a=gp.T(n)
    print n

#wait some time..
...
65535
65536
---------------------------------------------------------------------------
TypeError

TypeError: Error executing code in GP:
CODE:
        sage[131074]=65537;
PARI/GP ERROR:
  ***   at top-level: sage[131074]=65537
  ***                     ^--------------
  ***   array index (131074) out of allowed range [1-131073].

after this trying:

sage: gp.T(1)

again raises exception.

After the above computation, the log file .sage/gp-expect.log ends with

? sage[131070]=65535;
sage[131070]=65535;
? sage[131071]=T(sage[131070]);
sage[131071]=T(sage[131070]);
? sage=concat(sage, vector(131072,k,0));
sage=concat(sage, vector(131072,k,0));
  ***   at top-level: sage=concat(sage,vec
  ***                 ^--------------------
  ***   the PARI stack overflows !
  current stack size: 10000000 (9.537 Mbytes)
  [hint] you can increase GP stack with allocatemem()

? allocatemem()
allocatemem()
  ***   Warning: new stack size = 20000000 (19.073 Mbytes).
? sage=concat(sage, vector(131072,k,0));
sage=concat(sage, vector(131072,k,0));
? sage[131072]=65536;
sage[131072]=65536;
? sage[131073]=T(sage[131072]);
sage[131073]=T(sage[131072]);
? sage[131074]=65537;
sage[131074]=65537;
  ***   at top-level: sage[131074]=65537
  ***                     ^--------------
  ***   array index (131074) out of allowed range [1-131073].
?

It appears that the vector sage wasn't doubled correctly; probably it got messed up by the failed concat().

This could be related to #11017/#11018.

Component: interfaces

Keywords: gp stack overflow

Author: Peter Bruin

Branch/Commit: ab293b2

Reviewer: Alejandro Argaez

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

@pjbruin pjbruin added this to the sage-6.1 milestone Nov 22, 2013
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@pjbruin
Copy link
Contributor Author

pjbruin commented Feb 18, 2014

Commit: ab293b2

@pjbruin
Copy link
Contributor Author

pjbruin commented Feb 18, 2014

comment:2

The problem appears to be fixed by introducing a temporary variable to hold the result of concat() instead of directly assigning it to sage.

@pjbruin
Copy link
Contributor Author

pjbruin commented Feb 18, 2014

Author: Peter Bruin

@pjbruin
Copy link
Contributor Author

pjbruin commented Feb 18, 2014

Branch: u/pbruin/15446-gp_results_vector

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 20, 2014

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

229fd4cuse separate variables instead of a vector for GP results

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 20, 2014

Changed commit from ab293b2 to 229fd4c

@pjbruin
Copy link
Contributor Author

pjbruin commented Feb 20, 2014

comment:4

Never mind the commit in comment:3, this breaks when there are more than 65535 variables.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 20, 2014

Changed commit from 229fd4c to ab293b2

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 20, 2014

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

ab293b2fix resizing of GP results vector when stack overflow occurs

@pjbruin
Copy link
Contributor Author

pjbruin commented Feb 21, 2014

comment:7

Alejandro, could you fill in your name (more precisely your real name, not Trac username) in the "Reviewer" field?

@sagetrac-ArgaezG
Copy link
Mannequin

sagetrac-ArgaezG mannequin commented Feb 22, 2014

Reviewer: Alejandro Argaez

@vbraun
Copy link
Member

vbraun commented Feb 22, 2014

Changed branch from u/pbruin/15446-gp_results_vector to ab293b2

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

2 participants