Opened 6 years ago

Closed 5 years ago

#15446 closed defect (fixed)

GP interface confused by stack overflow when enlarging results vector

Reported by: pbruin Owned by:
Priority: major Milestone: sage-6.2
Component: interfaces Keywords: gp stack overflow
Cc: Merged in:
Authors: Peter Bruin Reviewers: Alejandro Argaez
Report Upstream: N/A Work issues:
Branch: ab293b2 (Commits) Commit: ab293b23647b01c03eae0e5c0a9f189ebcc2cc3c
Dependencies: Stopgaps:

Description

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.

Change History (9)

comment:1 Changed 6 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:2 Changed 5 years ago by pbruin

  • Authors set to Peter Bruin
  • Branch set to u/pbruin/15446-gp_results_vector
  • Commit set to ab293b23647b01c03eae0e5c0a9f189ebcc2cc3c
  • Status changed from new to needs_review

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

comment:3 Changed 5 years ago by git

  • Commit changed from ab293b23647b01c03eae0e5c0a9f189ebcc2cc3c to 229fd4c77e034dff5250277d4f9ecc030effe7c7

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

comment:4 Changed 5 years ago by pbruin

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

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

comment:5 Changed 5 years ago by git

  • Commit changed from 229fd4c77e034dff5250277d4f9ecc030effe7c7 to ab293b23647b01c03eae0e5c0a9f189ebcc2cc3c

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

comment:6 follow-up: Changed 5 years ago by ArgaezG

  • Status changed from needs_review to positive_review

comment:7 in reply to: ↑ 6 Changed 5 years ago by pbruin

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

comment:8 Changed 5 years ago by ArgaezG

  • Reviewers set to Alejandro Argaez

comment:9 Changed 5 years ago by vbraun

  • Branch changed from u/pbruin/15446-gp_results_vector to ab293b23647b01c03eae0e5c0a9f189ebcc2cc3c
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.