Help - Perl, XS and global constructors

hp

    Next

  • 1. LUN design and implementation
    GT Jeff Cherer < XXXX@XXXXX.COM > wrote in message news: XXXX@XXXXX.COM ... > Folks; > got a touchy problem. we ordered a half dozen disks from hp for our > n4000/fc60/sc10's. the quote had an item on it for a few times my weekly > salary. it was an 'option' called 'lun design and implementation'. i got the > disks and talked to our friendly ce. he said he wasn't familiar with the > option and had never actually done it (this is a pretty experienced and > sharp guy). we chatted the lun 'design' - that is, i told him our scheme and > to do it just like the others (simply mirror alternating slots). > does anyone know anything about this 'option'?? did i actually get it?? > i am deep in the bureaucracy, a real bottom feeder, and have no contact with > hp sales. however, i would really like to know if this is a standard option > with adding disks. what's the story?? > Sounds like a consulting service that someone has tacked on to the quote. It can be worthwhile the first time you get some new equipment but it is usually rather expensive, as you noted. If you don't want it make sure your tell your purchasing section not to order it.
  • 2. Modify Printer Queue destination
    Due to consoldation of servers I need to change a number of printer queues under HP UX 10 & 11. These queues are pointed to a remote server (ie: \\server2\admin)at this time, and will be \\server1\admin in a few days.. The problem is I have approx 90 queues to update on three different HP servers. I do not wish to manually use SAM if there is an easier way to complete this task. Prone to typos etc. This should be easy since only the server name is updated, remote queue etc is the same.
  • 3. tcl/tk hp-ux 11
    I have downloaded the depot version of Tcl/Tk 8.3.4 for HP-UX 11, and the following doesn't work well: say file test.tcl contain the following: frame .fr pack .fr set id [exec emb.tcl -use [winfo id .fr] &] and emb.tcl contain the following: button .bt -text "OK" -command exit this seem to work time to time (1 on 10) on HP-UX 11. It is actually a big problem as this is used in our simulation supervision HP-UX 10.20. We need to migrate to HP_UX 11, and this block us for testing our application. If somebody have any idee please let me know.
  • 4. Creating Volumes in HP !!
    All, I have used Veritas Volume managers in SUN. But never created the Volumes in HPUX. Can somone tell me how can I select the Volumes in HPUX ? Is there any white paper or Document out there ? Please let me know. Thanks again. From, Pranav Thaker. 732-750-4311.
  • 5. OT??? omnibook 600ct external fdd pinout
    My appologies if this is OT. I cant seem to find it anyware. I want add the little thing to my Amoeba cluster. I also refuse to pay 90 bucks for something I can wire up for almost nothing. I humbly thank you all in advance.

Help - Perl, XS and global constructors

Postby usenet.zaa.jabberwock » Sun, 08 May 2005 05:58:20 GMT

I have a third-party dynamic library that I'm trying to write an xsub
for.  It was written in C++, and it apparently has global constructors
that need to be initialized.  Building a static xsub works fine, but
the dynamic build always crashes in one function (naturally, it's a
function that needs to be called before almost all of the others in the
library).  With the static build running in wdb, I can actually see
code in the library being called from __do_global_ctors(), but not so
with a dynamic build, so I'm pretty sure it's a constructor problem.

Before I go into the gritty details, let me just ask the basic
question: can a dynamically loaded xsub be written for a library that
has global constructors that need to be initialized?

In my search for a solution, I came to believe that this was possible,
due to references to the CCsimple example in CookbookB.  It gives a
recipe for building a new perl executable that handles C++ constructors
(which I've done).  But how would perl know what constructors need to
be run, when the xsub (and hence the library) aren't loaded until the
perl interpreter starts running?  Did I misunderstand the CCsimple
example?  Note that my xsub code itself doesn't use c++, just the
library (and I only know that because it requires stdc++ to be linked
in).

I'm running HPUX 11, with a perl 5.8.6 that I built myself.  I've tried
building perl and the xsub with the HP ANSI C compiler (we don't have
the c++ compiler), g++ (with ld for linking), and g++ (for both
compiling and linking, which of course eventually calls ld anyway).
They all seem to behave about the same.

Any suggestions/guidance?  I can give more details about the xsub once
someone confirms that this is indeed possible.

Thanks.

Re: Help - Perl, XS and global constructors

Postby Mike Stroyan » Sat, 14 May 2005 05:08:38 GMT

  Older versions of perl would load shared libraries on HP-UX by calling
shl_load with a BIND_NOSTART flag.  That prevented shared library
initializers from running and calling c++ constructors.  Your 5.8.6 version
of perl should have had that corrected already.  Apparently it is not
corrected.  Look for BIND_NOSTART in ext/DynaLoader/dl_hpux.xs of your
perl source and take it out.

-- 
Mike Stroyan,  XXXX@XXXXX.COM 

Re: Help - Perl, XS and global constructors

Postby usenet.zaa.jabberwock » Sat, 14 May 2005 21:58:44 GMT

No, I think dl_hpux.xs is correct.  Here's the applicable section:
----------------------------------------------------------------------------
    if (dl_nonlazy) {
      bind_type = BIND_IMMEDIATE|BIND_VERBOSE;
    } else {
      bind_type = BIND_DEFERRED;
      /* For certain libraries, like DCE, deferred binding often causes
run
       * time problems.  Adding BIND_NONFATAL to BIND_IMMEDIATE still
allows
       * unresolved references in situations like this.  */
      /* bind_type = BIND_IMMEDIATE|BIND_NONFATAL; */
    }
    /* BIND_NOSTART removed from bind_type because it causes the shared
library's       */
    /* initialisers not to be run.  This causes problems with all of
the static objects */
    /* in the library.     */
#ifdef DEBUGGING
    if (dl_debug)
        bind_type |= BIND_VERBOSE;
#endif /* DEBUGGING */
----------------------------------------------------------------------------
There's no other occurrence of BIND_NOSTART in the file.

It sounds like you're saying this should work though, which is
encouraging.  Maybe it's not as simple as the global constructors
simply not getting called (which is less encouraging).

Any tips on how to debug this with wdb?  I tried setting a breakpoint
in the library at the same place where it goes to in the static build,
and it never hit it.  But maybe there's something going wrong earlier.
I tried a "catch load", but I got lost pretty quickly trying to step
through the library loading with no debug info.

Thanks for your help!

Re: Help - Perl, XS and global constructors

Postby usenet.zaa.jabberwock » Sat, 14 May 2005 23:54:06 GMT

I was finally able to get dynamic loading to work, but it's not the
ideal solution (although it is usable).

I built a static perl with an empty xsub (as described in
CookbookB/CCsimple), but I also linked in *all* of the required
libraries (the vendor lists lots of shared libraries that need to be
linked to in addition to the one I'm writing the xsub for; previously,
I had only tried linking the new perl with the one where it was
crashing).  Using this perl, I can now dynamically load the extension
for the library I want to access.

I'm guessing that this makes the program's startup code aware of the
libraries, and it handles the initialization just as if it were a full
static build.  Since the libraries in question are still shared, the
new perl executable isn't any bigger than the original (in fact, it's a
little smaller for some odd reason).  I suppose I could also rebuild
perl from scratch and give these as required libraries, but this is
easier.

The really bad thing was that I had to do the link by hand.  I tried
defining LIBS in the "perl Makefile.PL" command line, but it didn't get
passed to the final link.  No idea why.

I'd still like a better solution if someone can come up with one, but I
can live with this.

Similar Threads:

1.C++ global constructors in xsub?

Rather than bog this post down with my particular details, I'll just
ask the basic question:

Is it possible to write a dynamically-loaded xsub for a library that
has C++ global constructors?

I've googled this question to death and I haven't found a definite
answer one way or the other, although one post led me to believe that
building a new perl binary as described in CookbookB/CCsimple would
solve the problem.  It didn't, and I'm not sure how it could, but maybe
I'm missing something.

If I get a "yes", I'll follow up with the gory details of my problem.
But just so it's not completely open-ended, I'm running under HPUX
11.11, perl 5.8.6 (but I'd be willing to rebuild perl any way anyone
suggests).

2.Calling SUPER::constructor in the constructor

Is it possible to call the constructor that a function inherits from its
parent?  I tried calling SUPER:: and SUPER-> in a constructor and got
errors.  Am i correct in assuming that if I rewrite the constructor that
a copy of the parent object won't be available?

Thanks in advance,

Dan

3.Perl C, XS help

Hi,

I am trying port an Custom Perl module from one server to another. The
module uses C/XS and was built in 2001/2. I got the source and did
`perl Makefile.PL; make`. There was an error in one .c file:

...
store.c:592: error: 'my_perl' undeclared (first use in this function)
store.c:592: error: (Each undeclared identifier is reported only once
store.c:592: error: for each function it appears in.)

I solved that by adding

'static PerlInterpreter *my_perl;'  near the top of the file.

After make distclean; perl Makefile, make and the same error with a
different file. This time however, once I added the static declaration
I got this error:

store.c:13: error: expected '=', ',', ';', 'asm' or '__attribute__'
before '*' token

It refers to the static declaration mentioned above.

I am a super newbie when it comes to C and I know this might be
straying OT but does anyone know how I can make this static declartion
in the correct way or perhaps point me to a list that might be able to
help?

Thanx,
Dp.

4.XS help

Hello All,
 
I'm trying to call C routine from Perl using XS but some how my 'make test'
is failing. Following are the steps I did :
 
file: hypotenuse.h
      double hypotenuse(double x, double y); /* Func Declaration */
file: hypotenuse.c
      /* Func Definition */
     double hypotenuse(double x, double y)
     {
           return sqrt(x*x + y*y);
     }

Steps :
1.  h2xs -n Geometry -A -O -x -F '-I ../..' hypotenuse.h   /created XS
components
2. cd Geometry               // Went in the directory
3. cp ../hypotenuse.* .     // Copied header and source files in Dir
4. Added Geometry.o and hypotenuse.o as objects in Makefile.pl
5. Perl Makefile.pl  and make is ok
6. 'make test' is failing 
 
Do someone have any idea where I'm going wrong? I did not read perl doc for
XS yet :(.
 
Error logs:
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e"
"test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/Geometry....NOK 1
#   Failed test 'use Geometry;'
#   in t/Geometry.t at line 9.
#     Tried to use 'Geometry'.
#     Error:  Can't load
'/SES/rajni/claudio/rajni/myModule/Code/factorial/Geometry/blib/arch/auto/Ge
ometry/Geometry.so' for module Geometry:
/SES/rajni/claudio/rajni/myModule/Code/factorial/Geometry/blib/arch/auto/Geo
metry/Geometry.so: undefined symbol: hypotenuse at
/usr/lib/perl5/5.8.8/i586-linux-thread-multi/DynaLoader.pm line 230.
 
Thanks
Rajni
 
 
 

DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.

5.Help w/Class::Date Date.xs

6. Help with xs: converting I32 to int ?

7. Problem using more than 1 module in Windows (XS) - please help

8. Copy constructor and Dup method in Perl



Return to hp

 

Who is online

Users browsing this forum: No registered users and 63 guest