Opened 10 years ago

Closed 10 years ago

#11617 closed defect (fixed)

sending certain large strings to the gp PARI pexpect interface fails

Reported by: was Owned by: was
Priority: critical Milestone: sage-4.7.2
Component: interfaces Keywords:
Cc: Merged in: sage-4.7.2.alpha1
Authors: William Stein Reviewers: Mike Hansen
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by was)

In Sage-4.7 (on Linux and OS X), we have:

sage: '***' in gp.eval('a='+str(range(10^3)))
False
sage: '***' in gp.eval('a='+str(range(10^4)))
False
sage: '***' in gp.eval('a='+str(range(10^5)))
False
sage: '***' in gp.eval('a='+str(range(10^6)))
True

The "*" appearing in the output means that an error occurs. Looking further we find:

sage: print gp.eval('a='+str(range(10^6)))
  ***   [...] at: read("/scratch/wstei
  ***             ^--------------------
  ***   in function read: read("/scratch/wstei
...
  *** read: error opening input file: `/scratch/wstein/sage//temp/mod.math.washington.edu/17446//interface//tmp17449'.

Shockingly, looking at the file we are reading it we find that it contains:

sage: !more /scratch/wstein/sage//temp/mod.math.washington.edu/17446//interface//tmp17449
read("/scratch/wstein/sage//temp/mod.math.washington.edu/17446//interface//tmp17449")

So, instead of writing the long string we are supposed to read in, the file contains a single line asking to read in itself!

NOTE: This bug was originally observed by Zhibin Liang.

Attachments (1)

trac_11617.patch (1.1 KB) - added by was 10 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 10 years ago by was

  • Description modified (diff)

comment:2 Changed 10 years ago by was

Simpler input to give the problem:

sage: time gp._eval_line('a='+str(range(2*10^5)))[:70]
'  ***   [...] at: read("/scratch/wstei\n  ***             ^------------'
Time: CPU 0.12 s, Wall: 0.34 s

Changed 10 years ago by was

comment:3 Changed 10 years ago by was

  • Status changed from new to needs_review

This turns out to be an easy 1-line fix. The bug turned out to be caused because the "allow_use_file" option wasn't properly passed in the last recursive call to _eval_line in the _eval_line function. And I guess that option is important since the default (=True) isn't the right choice when sending the name of the command to read in the file itself. In particular, since

 eval_using_file_cutoff=50

if the filename of the file to read in (plus the read command) exceeded 50 characters, we were in big trouble... but only in the case when the stack was automatically doubled. This example hit this threshold.

comment:4 Changed 10 years ago by was

  • Summary changed from sending any large string at all to the gp PARI pexpect interface fails to sending certain large strings to the gp PARI pexpect interface fails

comment:5 Changed 10 years ago by mhansen

  • Authors set to William Stein
  • Reviewers set to Mike Hansen
  • Status changed from needs_review to positive_review

Looks good to me.

comment:6 Changed 10 years ago by jdemeyer

  • Merged in set to sage-4.7.2.alpha1
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.