]> git.pld-linux.org Git - packages/parigp.git/blame - perl-Math-Pari-crash-workaround.patch
- rediffed target_arch and Math-Pari crash-workaround patches
[packages/parigp.git] / perl-Math-Pari-crash-workaround.patch
CommitLineData
9a645ab3
JB
1Math::Pari doesn't work properly with Data::Dumper[1], so try at least to
2avoid crash when trying to DESTROY something restored from dump
3(most likely to happen on 64-bit machines, when Data::Dumper uses string
4instead of int for pointer values which don't fit in 32 bits).
5
6[1] Data::Dumper returns something like
7bless( do{\(my $o = POINTER_VAL)}, 'Math::Pari' );
8where POINTER_VAL is just value of pointer to already existing Pari
9object (which may be destroyed later!).
10
354a576f
JB
11--- Math-Pari-2.030518/Pari.xs.orig 2019-04-20 05:02:34.000000000 +0200
12+++ Math-Pari-2.030518/Pari.xs 2021-06-26 09:51:04.478020090 +0200
13@@ -1377,6 +1377,13 @@ moveoffstack_newer_than(SV* sv)
9a645ab3
JB
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++;
2500d324 26 SV_OAVMA_switch(nextsv, sv1, GENmovedOffStack); /* Mark as moved off stack. */
354a576f 27@@ -4285,7 +4292,7 @@ DESTROY(rv)
2500d324 28 long oldavma; /* The value of avma on the entry
9a645ab3
JB
29 * to function having the SV as
30 * argument. */
31- long howmany;
32+ long howmany = 0;
2500d324 33 SV_OAVMA_PARISTACK_get(sv, oldavma, ostack);
354a576f 34 oldavma += myPARI_bot;
9a645ab3 35 #if 1
354a576f 36@@ -4318,6 +4325,7 @@ DESTROY(rv)
9a645ab3
JB
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) {
354a576f 44@@ -4326,7 +4334,9 @@ DESTROY(rv)
9a645ab3
JB
45 avma = oldavma; /* Mark the space on stack as free. */
46 }
2500d324 47 PariStack = (SV*)ostack; /* The same on the Perl/PARI side. */
9a645ab3
JB
48+ }
49 }
50+ if (howmany >= 0)
51 SVnum_dec;
52 }
53
This page took 0.098214 seconds and 4 git commands to generate.