Skip to content

Commit

Permalink
do not assign clones to objects on the pari stack
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Kliem committed Jan 21, 2022
1 parent e2c9824 commit fa1216c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions cypari2/gen.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1531,6 +1531,11 @@ cdef class Gen(Gen_base):

self.cache((i,j), x)
xt = x.ref_target()

if not is_universal_constant(x.g):
# Make sure that self is on the heap, before we assign a clone to it.
self.fixGEN()

set_gcoeff(self.g, i+1, j+1, xt)
return

Expand All @@ -1555,6 +1560,10 @@ cdef class Gen(Gen_base):

self.cache(i, x)
xt = x.ref_target()
if not is_universal_constant(x.g):
# Make sure that self is on the heap, before we assign a clone to it.
self.fixGEN()

if typ(self.g) == t_LIST:
listput(self.g, xt, i+1)
else:
Expand Down
6 changes: 5 additions & 1 deletion cypari2/pari_instance.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,10 @@ cdef class Pari(Pari_auto):
if len(entries) != m * n:
raise IndexError("len of entries (=%s) must be %s*%s=%s"%(len(entries),m,n,m*n))
k = 0

# Make sure that A is on the heap, before we assign clones to it.
A.fixGEN()

for i in range(m):
for j in range(n):
sig_check()
Expand All @@ -1318,7 +1322,7 @@ cdef class Pari(Pari_auto):
If the second argument `p` is specified, it must be a prime.
Then only the local information at `p` is computed and returned.
Examples:
>>> import cypari2
Expand Down

0 comments on commit fa1216c

Please sign in to comment.