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

DynaLoader/dl_aix.xs problem using load and unload on AIX #690

Closed
p5pRT opened this issue Oct 7, 1999 · 3 comments
Closed

DynaLoader/dl_aix.xs problem using load and unload on AIX #690

p5pRT opened this issue Oct 7, 1999 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Oct 7, 1999

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

Searchable as RT1588$

@p5pRT
Copy link
Author

p5pRT commented Oct 7, 1999

From bealzy@us.ibm.com

Created by bealzy@us.ibm.com

I have identified a problem with Perl's DynaLoader/dl_aix.xs
which is very specific to the IBM AIX platform.
This problem is specific to Perl to C extensions that
first call C functions but the C functions call C++ functions
and the C++ code makes use of statics. The statics are not
getting initialized. To get them to initialize properly the
load and unload function calls in DynaLoader/dl_aix.xs need to be
replaced with libC_r.a function calls loadAndInit and
terminateAndUnload. dl_aix.xs also now needs
to include the load.h file, on my system I included
#include </usr/ibmcxx/include/load.h>. In addition, the code
now needs to link with -lC_r.
Making these changes should not impact any extension that
doesn't require this fix.

If for some reason you do not want to patch dl_aix.xs, I would
strongly recommend that at a minimum a README for aix (README.aix)
be created that identifies this problem and suggests this work around.

Linking with libC_r.a should not be a problem since it is
shipped with base AIX. This change was made to the Perl code
that is now shipped with AIX 4.3.3. I just put a post out to
comp.lang.perl.misc today (October 7, 1999) announcing this.
I have also been using both Perl5.005_02 and then Perl5.005_03 fixed
with my patch for roughly one year and it has not broken any other
part of Perl. I have now, twice in the last 3 weeks, been contacted
by two different IBMers, one in IBM Research and one in Burlington
Vermont, confirming that this fix was also required for some of
their Perl to C extensions to work properly.

This was one of the most difficult bugs that I've had to
tackle in IBM. Patching base Perl specifically the
DynaLoader/dl_aix.xs will save many other people from the
4 weeks of pain that I went through. Being a new developer
of Perl to C extensions last year, I first
assumed this problem was in my code, it wasn't, next I figured
it must be in the code I was calling, it wasn't, finally
after scanning through many IBM internal news groups I hit
on a similar fix someone had to make to Rexx calling C calling
C++. The fix worked for me and was very easy to make.
For people outside of IBM who don't have access to our internal
news groups this would be an extremely painful bug to resolve.

I would be very willing to download and build a new level of Perl
that includes this fix to verify that the fix was done correctly
and works on the 1 out of 5 of my extensions that requires it.

Please feel free to contact me with questions!
Stephanie Beals
bealzy@​us.ibm.com
(914) 433-7948

Perl Info


Site configuration information for perl 5.00503:

Configured by root at Wed Aug 11 15:58:01 CDT 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=aix, osvers=4.3.3.0, archname=aix
    uname='aix funny 3 4 000001716600 '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O', gccversion=
    cppflags='-D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE -qmaxmem=16384'
    ccflags ='-D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE -qmaxmem=16384'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
    alignbytes=8, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='ld', ldflags ='-s'
    libpth=/lib /usr/lib /usr/ccs/lib
    libs=-lnsl -ldbm -ldl -lld -lm -lc -lcrypt -lbsd -lPW -lC_r
    libc=/lib/libc.a, so=a, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_aix.xs, dlext=so, d_dlsymun=undef, ccdlflags='-bE:perl.exp'
    cccdlflags=' ', lddlflags='-bhalt:4 -bM:SRE -bI:$(PERL_INC)/perl.exp -bE:$(B
ASEEXT).exp -b noentry -lc'

Locally applied patches:



@INC for perl 5.00503:
    /usr/opt/perl5/lib/5.00503/aix
    /usr/opt/perl5/lib/5.00503
    /usr/opt/perl5/lib/site_perl/5.005/aix
    /usr/opt/perl5/lib/site_perl/5.005
    .


Environment for perl 5.00503:
    HOME=/
    LANG=en_US
    LANGUAGE (unset)
    LC__FASTMSG=true
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/lpp/ssp/bin:/u
sr/lib/instl:/usr/bin:/usr/lpp/ssp/kerberos/bin:/var/ifor:/usr/opt/ifor/ls/conf
    PERL_BADLANG (unset)
    SHELL=/bin/ksh

@p5pRT
Copy link
Author

p5pRT commented Oct 7, 1999

From @jhi

Could you please download the latest developer snapshot from

  http​://www.iki.fi/jhi/cfgperl4306.tar.gz

and retry with that.

I have no misconceptions that the snapshot will work any better for
the particular problem you describe, but any patches you supply should
very preferably be against the above version. The dl_aix.xs (and
other things relevant to AIX, such as building perl.exp) have changed
somewhat since the 5.005_03.

But, I have a slew of questions...

You say "To get them to initialize properly the load and unload
function calls in DynaLoader/dl_aix.xs need to be replaced with
libC_r.a function calls loadAndInit and terminateAndUnload."
Ummm. Will non-C++-non-statics extensions load okay, too, with the
loadAndInit and terminateAndUnload, really? Just doublechecking.

How are the loadAndInit() and terminateAndUnload() used? I do not
have the IBM C++ compiler installed in the AIX boxes I have access to
so I don't know.

#include </usr/ibmcxx/include/load.h>

Ummm, not any less strange path available? Absolute paths inside
the <> construct look kinda funny.

Linking with libC_r.a should not be a problem since it is
shipped with base AIX.

Since AIX version 3? (Yeah, I guess it's no more supported...but
still.) Since AIX version 4.something? If the loadAndInit() and
terminateAndUnload() are not available in *all* versions of AIX
then we have problem​: we need to be able to detect whether we have
them (we can do this in hints/aix.sh, if need be).

And which one does need to be linked with -lC_r? Perl itself?
Or just the Dynaloader extension?

Don't get me wrong​: while I'm rather wary above, I appreciate your
detective work. But we need (a) backward compatibility and
(b) clean fixes, and to get these, I need answers to my above doubts...

While the above snapshot is from the development strain leading into
Perl 5.6 (the next major release) and as such probably not 100%
applicable to the 5.005 branch, the goal is to backport most of the
enhancements from 5.6 back to the 5.005. Fixing dynaloading is
definitely something that should be backported.

--
$jhi++; # http​://www.iki.fi/jhi/
  # There is this special biologist word we use for 'stable'.
  # It is 'dead'. -- Jack Cohen

@p5pRT
Copy link
Author

p5pRT commented Oct 8, 1999

From [Unknown Contact. See original ticket]

On Thu, 7 Oct 1999 bealzy@​us.ibm.com wrote​:

Linking with libC_r.a should not be a problem since it is
shipped with base AIX. This change was made to the Perl code
that is now shipped with AIX 4.3.3. I just put a post out to

So perl is now shipping with AIX 4.3.3? Cool! And may I say, it's about
time! ;-)

John.

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

No branches or pull requests

1 participant