develooper Front page | perl.perl5.porters | Postings from June 2002

[ID 20020626.004] dl_dyld.xs uses ancient api

From:
Peter O'Gorman
Date:
June 26, 2002 05:53
Subject:
[ID 20020626.004] dl_dyld.xs uses ancient api
Message ID:
6D23F858-884C-11D6-9A40-003065F6C222@pogma.com
This is a bug report for perl from peter@localhost.nonet,
generated with the help of perlbug 1.33 running under perl v5.8.0.


-----------------------------------------------------------------
[Please enter your report here]
Patch for dl_dyld.xs
Includes fixes to stop perl from exiting when an error occurs 
loading a module

And a patch to only look in the loaded module for the requested 
symbol, rather than
the global namespace

Note that this passes make check with the same failures as the 
current (5.8-rc2).


diff -urN perl-5.8.0-RC1/ext/DynaLoader/dl_dyld.xs 
perl/ext/DynaLoader/dl_dyld.xs
--- perl-5.8.0-RC1/ext/DynaLoader/dl_dyld.xs    Sun Jun  2 02:02:54 2002
+++ perl/ext/DynaLoader/dl_dyld.xs      Tue Jun 25 10:06:47 2002
@@ -37,6 +37,8 @@

  */

+
+
  #include "EXTERN.h"
  #include "perl.h"
  #include "XSUB.h"
@@ -54,9 +56,13 @@
      return dl_last_error;
  }

-int dlclose(handle) /* stub only */
+static int dlclose(handle)
  void *handle;
  {
+/*
+       Leave this alone for now, may cause problems...
+       (void*)NSUnLinkModule( handle, NSUNLINKMODULE_OPTION_NONE );
+ */
      return 0;
  }

@@ -110,30 +116,36 @@

      dyld_result = NSCreateObjectFileImageFromFile(path, &ofile);
      if (dyld_result != NSObjectFileImageSuccess)
-       TranslateError(path, OFImage, dyld_result);
+               TranslateError(path, OFImage, dyld_result);
      else
      {
         // NSLinkModule will cause the run to abort on any link error's
         // not very friendly but the error recovery 
functionality is limited.
-       handle = NSLinkModule(ofile, path, TRUE);
-       NSDestroyObjectFileImage(ofile);
+               handle = NSLinkModule(ofile, path,      
NSLINKMODULE_OPTION_BINDNOW |
+                                                                
               NSLINKMODULE_OPTION_PRIVATE |
+                                                                
               NSLINKMODULE_OPTION_RETURN_ON_ERROR );
+               if (!handle)
+               {
+                       NSLinkEditErrors ler;
+                       int lerno;
+                       const char* errstr;
+                       const char* file;
+                       NSLinkEditError(&ler,&lerno,&file,&errstr);
+               safefree(dl_last_error);
+               dl_last_error = savepv(errstr);
+               }
+               NSDestroyObjectFileImage(ofile);
      }
-
      return handle;
  }

-void *
+static void *
  dlsym(handle, symbol)
  void *handle;
  char *symbol;
  {
-    void *addr;
-
-    if (NSIsSymbolNameDefined(symbol))
-       addr = NSAddressOfSymbol(NSLookupAndBindSymbol(symbol));
-    else
-       addr = NULL;
-
+    void *addr = NULL;
+       addr = NSAddressOfSymbol(NSLookupSymbolInModule(handle, 
symbol));
      return addr;
  }


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
     category=core
     severity=medium
---
Site configuration information for perl v5.8.0:

Configured by peter at Tue Jun 25 12:11:56 JST 2002.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
   Platform:
     osname=darwin, osvers=5.5, archname=darwin
     uname='darwin localhost 5.5 darwin kernel version 5.5: thu 
may 30 14:51:26 pdt 2002; root:xnuxnu-201.42.3.obj~1release_ppc 
power macintosh powerpc '
     config_args='-ds -e -Dprefix=/usr -Dccflags=-g  -pipe  -Dldflags='
     hint=recommended, useposix=true, d_sigaction=define
     usethreads=undef use5005threads=undef useithreads=undef 
usemultiplicity=undef
     useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
     use64bitint=undef use64bitall=undef uselongdouble=undef
     usemymalloc=n, bincompat5005=undef
   Compiler:
     cc='cc', ccflags ='-g -pipe -pipe -fno-common 
-DINT32_MIN_BROKEN -DINT64_MIN_BROKEN -no-cpp-precomp 
-fno-strict-aliasing -I/usr/local/include',
     optimize='-O3',
     cppflags='-no-cpp-precomp -g -pipe -pipe -fno-common 
-DINT32_MIN_BROKEN -DINT64_MIN_BROKEN -no-cpp-precomp 
-fno-strict-aliasing -I/usr/local/include'
     ccversion='', gccversion='2.95.2 19991024 (release)', 
gccosandvers=''
     intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
     d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
     ivtype='long', ivsize=4, nvtype='double', nvsize=8, 
Off_t='off_t', lseeksize=8
     alignbytes=8, prototype=define
   Linker and Libraries:
     ld='cc', ldflags ='-flat_namespace -L/usr/local/lib'
     libpth=/usr/local/lib /usr/lib
     libs=-lm -lc
     perllibs=-lm -lc
     libc=/usr/lib/libc.dylib, so=dylib, useshrplib=true, 
libperl=libperl.dylib
   Dynamic Linking:
     dlsrc=dl_dyld.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
     cccdlflags=' ', lddlflags='-flat_namespace -bundle 
-undefined suppress -L/usr/local/lib'

Locally applied patches:


---
@INC for perl v5.8.0:
     /sw/lib/perl5/darwin
     /sw/lib/perl5
     /System/Library/Perl/darwin
     /System/Library/Perl
     /Library/Perl/darwin
     /Library/Perl
     /Library/Perl
     /Network/Library/Perl/darwin
     /Network/Library/Perl
     /Network/Library/Perl
     .

---
Environment for perl v5.8.0:
     DYLD_LIBRARY_PATH (unset)
     HOME=/Users/peter
     LANG (unset)
     LANGUAGE=en
     LD_LIBRARY_PATH (unset)
     LOGDIR (unset)
     PATH=/sw/bin:/sw/sbin:/Users/peter/bin/powerpc-apple-
darwin:/Users/peter/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/
sbin:/sbin:/usr/X11R6/bin
     PERL5LIB=/sw/lib/perl5
     PERL_BADLANG (unset)
     SHELL=/bin/tcsh




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About