Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

embedded perl causes problems when dynamically loaded #1339

Closed
p5pRT opened this issue Mar 14, 2000 · 3 comments
Closed

embedded perl causes problems when dynamically loaded #1339

p5pRT opened this issue Mar 14, 2000 · 3 comments

Comments

@p5pRT
Copy link

@p5pRT p5pRT commented Mar 14, 2000

Migrated from rt.perl.org#2367 (status was 'resolved')

Searchable as RT2367$

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Mar 14, 2000

From adrianh@adrianh.hq.tensilica.com

Created by adrianh@tensilica.com

I have had a hard time getting an embedded perl interpreter to work as a dynamically loaded module. I kept getting 'Bad free() ignored' at run time. It turns out that perl has its own memory management - fine, but it redefines malloc and free etc. That is bad when the library is dynamically loaded since the perl free routine 'shows up' after memory has already been managed by the libc routines. This might be fixable by passing different flags to the dynamic loader, but I do not have access to that routine since it is controled by a third party tool.

I consider it a bug that perl redefines malloc and free. I think they should be perl_malloc and perl_free or something like that.

As long as the names are not changed, it will be impossible to dynamically load a perl interpreter.

Thanks
Adrian

Perl Info


Site configuration information for perl 5.00502:

Configured by source at Wed Jun 23 13:40:14 PDT 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 2) configuration:
  Platform:
    osname=linux, osvers=2.0.33, archname=i686-linux
    uname='linux sonata 2.0.33 #49 wed jul 22 04:14:00 pdt 1998 i686 unknown '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O2', gccversion=2.7.2.3
    cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include -I/usr/xtensa/beta-source/cvsroot/StandardTools/perl5.005_02/../gdbm-1.7.3'
    ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include -I/usr/xtensa/beta-source/cvsroot/StandardTools/perl5.005_02/../gdbm-1.7.3'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib -L/usr/xtensa/beta-source/cvsroot/StandardTools/perl5.005_02/../gdbm-1.7.3'
    libpth=/usr/local/lib /usr/xtensa/beta-source/cvsroot/StandardTools/perl5.005_02/../gdbm-1.7.3 /lib /usr/lib
    libs=-lnsl -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib -L/usr/xtensa/beta-source/cvsroot/StandardTools/perl5.005_02/../gdbm-1.7.3'

Locally applied patches:
    


@INC for perl 5.00502:
    /usr/xtensa/stools/lib/perl5/5.00502/i686-linux
    /usr/xtensa/stools/lib/perl5/5.00502
    /usr/xtensa/stools/lib/perl5/site_perl/5.005/i686-linux
    /usr/xtensa/stools/lib/perl5/site_perl/5.005
    .


Environment for perl 5.00502:
    HOME=/home/adrianh
    LANG (unset)
    LD_LIBRARY_PATH=/usr/lib:/usr/local/lib:/usr/dt/lib:/usr/openwin/lib
    LOGDIR (unset)
    PATH=.:/home/adrianh/bin:/usr/xtensa/stools/bin:/home/adrianh/bin/xtools/bin:/bin:/opt/SUNWspro/bin:/usr/ucb/bin:/usr/ccs/bin:/usr/sbin:/usr/dt/bin:/usr/local/bin:/usr/local/libexec:/usr/local/lsf/bin:/usr/bin:/usr/openwin/bin:/cad/cds/S97BNC/tools/bin:/cad/cds/S97BNC/tools/dfII/bin:/cad/syssc2/vera-4.3-solaris2.5/bin:/cad/summit/HDLScore/bin:/cad/signalscan/solaris/signalscan-6.2/sparc-solaris/bin:/home/davel/0in_stable/stable.sun/sun4os5/bin:/cad/continuum/vtv197:/cad/modeltech/modeltech_v5.2:/cad/interHDL/checkit-1.18:/cad/interHDL/coverIt-1.10:/cad/interHDL/verilint-4.13:/cad/interHDL/intervhdl-1.57:/cad/interHDL/testit-2.06:/cad/vcs/vcs5.0.1A/sun_sparc_solaris_5.4/bin:/cad/cds/S97BNC/tools/bin:/cad/cds/S97BNC/tools/dfII/bin:/cad/cds/S97BNC/tools/pcb/bin:/opt/kde/bin:/usr/X11R6/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash


@p5pRT
Copy link
Author

@p5pRT p5pRT commented Mar 14, 2000

From @gsar

On Tue, 14 Mar 2000 09​:27​:21 PST, Adrian Harris wrote​:

I have had a hard time getting an embedded perl interpreter to work as a dynamically loa
ded module. I kept getting 'Bad free() ignored' at run time. It turns out that perl has
its own memory management - fine, but it redefines malloc and free etc. That is bad when
the library is dynamically loaded since the perl free routine 'shows up' after memory h
as already been managed by the libc routines. This might be fixable by passing different
flags to the dynamic loader, but I do not have access to that routine since it is contr
oled by a third party tool.

I consider it a bug that perl redefines malloc and free. I think they should be perl_mal
loc and perl_free or something like that.

This issue has been fixed for good for Perl 5.6.0. #define EMBEDMYMALLOC
in older versions of Perl, or simply don't build Perl to use its own
malloc.

Sarathy
gsar@​ActiveState.com

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Mar 15, 2000

From @doughera88

On Tue, 14 Mar 2000, Adrian Harris wrote​:

I have had a hard time getting an embedded perl interpreter to work as
a dynamically loaded module. I kept getting 'Bad free() ignored' at
run time. It turns out that perl has its own memory management - fine,
but it redefines malloc and free etc. That is bad when the library is

Site configuration information for perl 5.00502​:

alignbytes=4\, usemymalloc=n\, prototype=define

This is odd. Since you are not using perl's malloc(), perl doesn't
redefine it for you. I just tested it myself to confirm this.

In 5.6.0, even with usemymalloc=y, perl also won't redefine malloc() for
you.

  Andy Dougherty doughera@​lafayette.edu
  Dept. of Physics
  Lafayette College, Easton PA 18042

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant