Memory Leak in Math::Pari

From: Ilya Zakharevich (nospam-abuse_at_ilyaz.org)
Date: 12/16/04


Date: Thu, 16 Dec 2004 05:21:50 +0000 (UTC)


>From documentation of v2.010601:

     A memory leak on the PARI stack was possible in a rare situaton:
        if a PARI function returning a value which is not on stack
        (very few possibilities: gnil, gun etc.) is called when no
        Math::Pari temporary values are on stack, the GENs created for
        the function arguments would leak.

I think some people saw this leak before, but since it was so hard to
reproduce, suffered from it silently. Please retest Math::Pari if you
had "PARI stack overflow" errors.

Thanks for your patience,
Ilya

P.S. It can take several hours for this version to propagate to CPAN.

P.P.S. Actual code to reproduce the leak is very simple; I found it
        mostly by luck (or a misprint ;-). Do

               $z = PARI 0;
               LOOP_OVER_THIS: $x = 256*$z;

        The PARI code for multiplication recognizes multiplication by
        0, so it returns the globally defined constant 0, which
        prohibits freeing the result of conversion of Perl value 256
        to a PARI value.



Relevant Pages

  • Re: Memory leak in Tk on X11? (apparent in demos/widget)
    ... > I'm experiencing memory leaks in Tk-based applications running under ... > reproduce the leak on two different SuSE boxes using different video ... The leak appers in X process, ...
    (comp.lang.tcl)
  • Memory leak in Tk on X11? (apparent in demos/widget)
    ... I'm experiencing memory leaks in Tk-based applications running under ... The leak appers in X process, ... I asked a friend to try to reproduce this on RedHat 9 but he didn't ...
    (comp.lang.tcl)
  • Re: Excel Math Bug
    ... not one that I can reproduce). ... operators" subtopic "The order in which Excel performs operations in ... languages that they use. ... so our ignorance of their documentation ...
    (microsoft.public.excel.programming)
  • Re: DBI::_new_handle leak?
    ... to help track down the leaks. ... Or build-up a small script from scratch that demonstrates the leak. ... if you can't reproduce the leak quickly then it gets very risky. ... I'll happily help find and fix a leak in the DBI *if* you can provide me ...
    (perl.dbi.users)
  • Re: LoadCursorFromFile
    ... > I can see no reference to that in the current copy of the MSDN ... > documentation I have. ... Have a look at 'Cursor Destruction': ... Ok, tried that now and yes, it resolves the leak. ...
    (microsoft.public.win32.programmer.gdi)