]> git.pld-linux.org Git - packages/parigp.git/blob - perl-Math-Pari-crash-workaround.patch
6e4d1b517fcfe719b81056c3d8c6dc6334074132
[packages/parigp.git] / perl-Math-Pari-crash-workaround.patch
1 Math::Pari doesn't work properly with Data::Dumper[1], so try at least to
2 avoid crash when trying to DESTROY something restored from dump
3 (most likely to happen on 64-bit machines, when Data::Dumper uses string
4 instead of int for pointer values which don't fit in 32 bits).
5
6 [1] Data::Dumper returns something like
7 bless( do{\(my $o = POINTER_VAL)}, 'Math::Pari' );
8 where POINTER_VAL is just value of pointer to already existing Pari
9 object (which may be destroyed later!).
10
11 --- Math-Pari-2.01080605/Pari.xs.orig   2004-01-31 10:06:08.000000000 +0100
12 +++ Math-Pari-2.01080605/Pari.xs        2004-05-15 21:11:38.894463600 +0200
13 @@ -1285,6 +1285,13 @@
14    SV* nextsv;
15    long ret=0;
16    
17 +  /* check if it exists on stack to avoid crash */
18 +  for (sv1 = PariStack; sv1 != sv; sv1 = nextsv) {
19 +    nextsv = (SV *) SvPVX(sv1);
20 +    if((char*)nextsv == GENfirstOnStack)
21 +      return -1; /* not on stack! */
22 +  }
23 +  
24    for (sv1 = PariStack; sv1 != sv; sv1 = nextsv) {
25      ret++;
26      SV_OAVMA_switch(nextsv, sv1, GENmovedOffStack); /* Mark as moved off stack. */
27 @@ -3848,7 +3855,7 @@
28          long oldavma;                   /* The value of avma on the entry
29                                           * to function having the SV as
30                                           * argument. */
31 -        long howmany;
32 +        long howmany = 0;
33          SV_OAVMA_PARISTACK_get(sv, oldavma, ostack);
34          oldavma += bot;
35  #if 1
36 @@ -3881,6 +3888,7 @@
37              /* Now fall through: */
38  /* case (IV)GENfirstOnStack: */
39              /* Now sv is the newest one on stack. */
40 +            if (howmany >= 0) {
41              onStack_dec;
42              perlavma = oldavma;
43              if (oldavma > sentinel) {
44 @@ -3889,7 +3897,9 @@
45                  avma = oldavma;        /* Mark the space on stack as free. */
46              }
47              PariStack = (SV*)ostack; /* The same on the Perl/PARI side. */
48 +            }
49          }
50 +        if (howmany >= 0)
51          SVnum_dec;
52       }
53  
This page took 0.114834 seconds and 2 git commands to generate.