Mailing List Archive

Jumbo DynaLoader patch for Perl5.001m
Re: Jumbo DynaLoader patch for Perl5.001m [ In reply to ]
On Fri, 15 Sep 1995, Tim Bunce wrote:

> I've only added load-only-once logic to dl_next.xs. Native dlopen()
> doesn't needs it and neither does the AIX dlopen() emulation since they
> do reference counting. HP-UX doesn't need it and VMS doesn't _need_ it.
> That just leaves GNU DLD. Any DLD users care to comment?

Care to give a simple (perhaps pseduo-code) example of what would be
affected by load-only-one? DLD is enough of a hack that any particular
behaviour (or lack of same) is up for grabs.

--
Kenneth Albanowski (kjahds@kjahds.com, CIS: 70705,126)
Re: Jumbo DynaLoader patch for Perl5.001m [ In reply to ]
> From: Kenneth Albanowski <kjahds@kjahds.com>
>
> On Fri, 15 Sep 1995, Tim Bunce wrote:
>
> > I've only added load-only-once logic to dl_next.xs. Native dlopen()
> > doesn't needs it and neither does the AIX dlopen() emulation since they
> > do reference counting. HP-UX doesn't need it and VMS doesn't _need_ it.
> > That just leaves GNU DLD. Any DLD users care to comment?
>
> Care to give a simple (perhaps pseduo-code) example of what would be
> affected by load-only-one? DLD is enough of a hack that any particular
> behaviour (or lack of same) is up for grabs.
>
I've deleted the original message now but in essence...

In a perl compiled with -DMULTIPLICITY each interpreter is likely to
load one or more perl extensions which have already been loaded by
another interpreter.

This is obviously essential at the per-interpreter level (newXS etc)
but can cause problems at the process level when an attempt is made
to load another copy of a shared object (duplicate symbols etc).

Most systems, such as dlopen(), keep track of what's been loaded and
just increment an internal reference count when an attempt is made to
load another copy of an object.

Some systems (currently only NeXT for sure) don't do this and so you
get duplicate symbol errors. The patch fixes this using a static hash
to store the paths of already loaded files.

Does that help?

Tim.
Re: Jumbo DynaLoader patch for Perl5.001m [ In reply to ]
On Fri, 15 Sep 1995, Tim Bunce wrote:

> Most systems, such as dlopen(), keep track of what's been loaded and
> just increment an internal reference count when an attempt is made to
> load another copy of an object.
>
> Some systems (currently only NeXT for sure) don't do this and so you
> get duplicate symbol errors. The patch fixes this using a static hash
> to store the paths of already loaded files.
>
> Does that help?

Yes. So a simple:

link_library("libfoo");
link_library("libfoo");

should be enough to tell whether it's a problem, right? (Also it'll say
whether the library get's loaded into memory once or twice.)

> Tim.

--
Kenneth Albanowski (kjahds@kjahds.com, CIS: 70705,126)
Re: Jumbo DynaLoader patch for Perl5.001m [ In reply to ]
> From: Kenneth Albanowski <kjahds@kjahds.com>
>
> On Fri, 15 Sep 1995, Tim Bunce wrote:
>
> > Most systems, such as dlopen(), keep track of what's been loaded and
> > just increment an internal reference count when an attempt is made to
> > load another copy of an object.
> >
> > Some systems (currently only NeXT for sure) don't do this and so you
> > get duplicate symbol errors. The patch fixes this using a static hash
> > to store the paths of already loaded files.
> >
> > Does that help?
>
> Yes. So a simple:
>
> link_library("libfoo");
> link_library("libfoo");
>
> should be enough to tell whether it's a problem, right? (Also it'll say
> whether the library get's loaded into memory once or twice.)
>
I would think so.

Tim.
Re: Jumbo DynaLoader patch for Perl5.001m [ In reply to ]
Tim,

> I've only added load-only-once logic to dl_next.xs. Native
> dlopen() doesn't needs it and neither does the AIX dlopen()
> emulation since they do reference counting. HP-UX doesn't need it
> and VMS doesn't _need_ it. That just leaves GNU DLD. Any DLD users
> care to comment?
>
> In a perl compiled with -DMULTIPLICITY each interpreter is likely
> to load one or more perl extensions which have already been loaded
> by another interpreter.

That is nice. However, it does not work as advertised, due to a bug
in dlutils.c:

#ifdef DL_LOADONCEONLY
static HV *dl_loaded_files;
#endif
Re: Jumbo DynaLoader patch for Perl5.001m [ In reply to ]
Sorry about the last (incomplete) mail, it is not a good idea
to have a line with a single dot in it within mail...

Here the complete mail:

Tim,

> I've only added load-only-once logic to dl_next.xs. Native
> dlopen() doesn't needs it and neither does the AIX dlopen()
> emulation since they do reference counting. HP-UX doesn't need it
> and VMS doesn't _need_ it. That just leaves GNU DLD. Any DLD users
> care to comment?
>
> In a perl compiled with -DMULTIPLICITY each interpreter is likely
> to load one or more perl extensions which have already been loaded
> by another interpreter.

That is nice. However, it does not work as advertised, due to a bug
in dlutils.c:

#ifdef DL_LOADONCEONLY
static HV *dl_loaded_files;
#endif
...
#ifdef DL_LOADONCEONLY
dl_loaded_files = newHV(); /* provide cache for dl_*.xs if needed */
#endif

The above code does not work, when multiple perls are instantiated.
Please modify it like this:

#ifdef DL_LOADONCEONLY
static HV *dl_loaded_files=0;
#endif
...
#ifdef DL_LOADONCEONLY
if(!dl_loaded_files)
dl_loaded_files = newHV(); /* provide cache for dl_*.xs if needed */
#endif


And while we are modifying DynaLoader:

In dl_next.xs, please move the two lines:

#include <mach-o/rld.h>
#include <streams/streams.h>

above the line

#include "EXTERN.h"

Otherwise it will not compile with -DEMBED.

Thank You, and I promise to learn diff real soon now!

Gerd Knops
Re: Jumbo DynaLoader patch for Perl5.001m [ In reply to ]
> From: Gerd Knops <gerti@bitart.com>
>
> > I've only added load-only-once logic to dl_next.xs. Native
> > dlopen() doesn't needs it and neither does the AIX dlopen()
> > emulation since they do reference counting. HP-UX doesn't need it
> > and VMS doesn't _need_ it. That just leaves GNU DLD. Any DLD users
> > care to comment?
> >
> > In a perl compiled with -DMULTIPLICITY each interpreter is likely
> > to load one or more perl extensions which have already been loaded
> > by another interpreter.
>
> That is nice. However, it does not work as advertised, due to a bug
> in dlutils.c:
>
I'll put together a patch over the jumbo DynaLoader patch for this.

Thanks.

Tim.
Re: Jumbo DynaLoader patch for Perl5.001m [ In reply to ]
Tim Bunce writes:
> I'll put together a patch over the jumbo DynaLoader patch for this.
>
> Thanks.
>
> Tim.
>

While we are here, can you please change

my($modfname) = $modparts[-1];

to

my($modfname) = $modparts[-1];
$modfname = &modname2fname($modfname) if defined &modname2fname;

The names of DLL have restricted length on OS/2, even when FS allows
long names.

Ilya
Re: Jumbo DynaLoader patch for Perl5.001m [ In reply to ]
> From: Ilya Zakharevich <ilya@math.ohio-state.edu>
>
> Tim Bunce writes:
>
> > [ ... -DEMBED and dl_next.xs ...]
>
> > I'll put together a patch over the jumbo DynaLoader patch for this.
>
> While we are here, can you please change
>
> my($modfname) = $modparts[-1];
> to
> my($modfname) = $modparts[-1];
> $modfname = &modname2fname($modfname) if defined &modname2fname;
>
> The names of DLL have restricted length on OS/2, even when FS allows
> long names.
>
Okay, implemented as:

my @modparts = split(/::/,$module);
my $modfname = $modparts[-1];

# Some systems have restrictions on files names for DLL's etc.
# mod2fname returns appropriate file base name (typically truncated)
# It may also edit @modparts if required.
$modfname = &mod2fname(\@modparts) if defined &mod2fname;

my $modpname = join('/',@modparts);

The patch is ready but I won't post it till Monday to give you
a chance to comment on the above.

I'm looking forward to your dl_dll.xs :-)

Tim.