RE: memory leak in DBI XS bootstrap code



I don't see what you mean in the "INSTALL" that comes with perl 5.8.0 (that's what we're using). Can you be more specific? Would I need to build perl in a special way, or DBI, or both?

I was sort of hoping someone more familiar with the code might be able to pinpoint it (of course, this is always preferable to doing it myself).

Any further pointers are appreciated...

-edan

-----Original Message-----
From: Tim Bunce [mailto:Tim.Bunce@xxxxxxxxx]
Sent: Thursday, June 29, 2006 14:47
To: Ephraim Dan
Cc: dbi-users@xxxxxxxx
Subject: Re: memory leak in DBI XS bootstrap code

Try building perl with options to make valgrind leak tracing more
effective (see perl's INSTALL file). That may help you pinpoint
the problem.

Tim.

On Thu, Jun 29, 2006 at 04:33:40AM -0700, Ephraim Dan wrote:
I am experiencing what I believe to be a memory leak in the DBI
bootstrap code. This is a problem for me because I am embedding perl in a
long-running program, and DBI is being loaded over and over, so my program
grows and grows.

The problem appears to be in the following routines:

boot_DBI (in /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-
multi/auto/DBI/DBI.so)
XS_DBI__install_method (in /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-
thread-multi/auto/DBI/DBI.so)

I am using DBI 1.51

The tool "valgrind" (http://valgrind.org) can be used to reproduce the
leak using the following code:

---
File: embed_test.c
---

#include <EXTERN.h> /* from the Perl distribution */
#include <perl.h> /* from the Perl distribution */

static PerlInterpreter *my_perl; /*** The Perl interpreter ***/
EXTERN_C void xs_init (pTHX); /*** init dyn. loading ***/

int main(int argc, char **argv, char **env)
{
char *embedding[] = { "", "-e", "0" };
my_perl = perl_alloc();
perl_construct(my_perl);
perl_parse(my_perl, xs_init, 3, embedding, (char **)NULL);
PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
perl_run(my_perl);
eval_pv("use DBI", TRUE);
perl_destruct(my_perl);
perl_free(my_perl);
}

---
File: Makefile
---

CC_OPTS = $(shell perl -MExtUtils::Embed -e ccopts)
LD_OPTS = $(shell perl -MExtUtils::Embed -e ldopts)

EXE = embed_test

$(EXE): xsinit.o embed_test.o
gcc -o $(EXE) embed_test.o xsinit.o $(LD_OPTS)

embed_test.o: embed_test.c
gcc -c embed_test.c $(CC_OPTS)

xsinit.o: xsinit.c
gcc -c xsinit.c $(CC_OPTS)

xsinit.c:
perl -MExtUtils::Embed -e xsinit -- -o xsinit.c

clean:
rm -f *.o xsinit.c $(EXE)

---
EOF
---

Can anyone suggest a fix for this? I'd be more than willing to take a
patch to DBI 1.51 as soon as someone has one.

Thanks,
Ephraim Dan



Relevant Pages

  • Installing DBI and DBD::TSM
    ... I am having trouble installing DBI. ... This is perl, v5.8.0 built for aix-thread-multi ... blib/lib/DB ... You can install them any time after installing the DBI. ...
    (perl.dbi.users)
  • Problem of installing DBI packages
    ... my curent configuration of HP Unix system is as below: ... When i do>>perl makefile.PL, ... You can install them any time after installing the DBI. ...
    (perl.dbi.users)
  • Re: DBI Installation Problems
    ... In case if anyone else has this ELFCLASS problem in the future when building DBI & DBD::Oracle on Solaris 10 using a 32-bit Perl installation, here is what worked for me. ... Next you can install DBI as it is normally setup... ... wrong ELF class: ELFCLASS64 at ...
    (perl.dbi.users)
  • Problems installing DBD::mysql on Solaris 10
    ... I am in the process of building a server and am trying to get Perl, ... I proceeded to install mysql, ... new copy of perl, using gcc. ...
    (comp.lang.perl.modules)
  • Re: Fwd: Installing DBI using gcc
    ... Subject: Installing DBI using gcc ... have a sun compiler available, nor do I have root authority. ... If you must use GCC, build your own Perl (5.10.0, therefore, not the archaic ... install locally to - ahem install Perl locally... ...
    (perl.dbi.users)