[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference vaxaxp::vmsnotes

Title:VAX and Alpha VMS
Notice:This is a new VMSnotes, please read note 2.1
Moderator:VAXAXP::BERNARDO
Created:Wed Jan 22 1997
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:703
Total number of notes:3722

626.0. "LIB$FIND_IMAGE_SYMBOL hangs in V7.1?" by CSC64::HENNING (A rose with no thorns) Wed May 21 1997 15:09

    Dear all,

    Appreciate your input on this problem.  Am also cross-posting this in 
    C++ notes, in case the problem is CRTL-related.

    a C++ program (FILE1) calls LIB$FIND_IMAGE_SYMBOL to map routine FOO
    from shareable image FILE2.  Routine FOO will also call FIS to map
    routine BAR from shareable image FILE3.  Attached procedure builds a
    test case (ok, code is a bit scuzzy ...).

    On OpenVMS Alpha V6.2 (DEC C++ V5.0), program completes w/o error:

      $ define/job file2 dka500:[henning]file2.exe
      $ define/job file3 dka500:[henning]file3.exe
      $!
      $ run file1
      In routine FOO.  Calling FIS to map BAR in image FILE3
      Entered BAR...
      Back in FOO
      $ deas/job file2
      $ deas/job file3

    On OpenVMS Alpha V7.1 (DEC C++ V5.5), execution hangs:

      $ define/job file2 dka500:[henning]file2.exe
      $ define/job file3 dka500:[henning]file3.exe
      $!
      $ run file1
      In routine FOO.  Calling FIS to map BAR in image FILE3

    Execution also hangs if I execute the images from V6.2 on the V7.1
    system. 

    On the V7.1 system, the process hangs in LEF state, with no outstanding
    lock requests.  The PC is in PROCESS_MANAGEMENT (offset 0001DA18). 
    Module EXE_STD$SYNCH_LOOP, at a "$CALL64 SYS$SYNCH_INT" statement.
    
    I can IPMT this as is, but appreciate your thoughts as to the cause.

    Thanks in advance,
    Mary
    

$ create file1.cxx
#include lib$routines
#include descrip

int main (int argc, char **argv) {

  $DESCRIPTOR (def_spec, "FACTSET:.EXE");
  $DESCRIPTOR (img_spec, "FILE2");
  $DESCRIPTOR (rtn_spec, "FOO");
  void (*pFoo)();

  int status = lib$find_image_symbol (&img_spec, &rtn_spec, 
					&pFoo, &def_spec);
  pFoo();
}

$ create file2.cxx
#include <stdio.h>
#include lib$routines
#include descrip

class A {
public:
  A() {
    $DESCRIPTOR (def_spec, "FACTSET:.EXE");
    $DESCRIPTOR (img_spec, "FILE3");
    $DESCRIPTOR (rtn_spec, "BAR");
    void (*pBar)();
    printf("In routine FOO.  Calling FIS to map BAR in image FILE3\n");
    int status = lib$find_image_symbol (&img_spec, &rtn_spec, 
					&pBar, &def_spec);

     pBar();
  }
};

A anInstance;

extern "C" {
  void foo();
}

void foo() {
  printf("Back in FOO\n");
}

$ create file3.cxx
#include <stdio.h>
#include lib$routines
#include descrip

extern "C" {
  void bar();
}

void bar() {
  printf("Entered BAR...\n");
}

$ cxx /lis /nowarn FILE1.CXX
$ cxx /lis /nowarn FILE2.CXX
$ cxx /lis /nowarn FILE3.CXX
$ link FILE1.OBJ
$ link/share=FILE2.EXE SYS$INPUT/opt
name=FILE2
identification="V1.001"
gsmatch=LEQUAL, 1, 001
FILE2.OBJ
symbol_vector=(FOO=procedure)
$!
$ link/share=FILE3.EXE SYS$INPUT/opt
name=FILE3
identification="V1.001"
gsmatch=lequal, 1, 001
FILE3.OBJ
symbol_vector=(BAR=procedure)

$ define/job file2 user1:[henning.test]file2.exe
$ define/job file3 user1:[henning.test]file3.exe
$!
$ run file1
$ deas/job file2
$ deas/job file3

    
T.RTitleUserPersonal
Name
DateLines
626.1CSC64::BLAYLOCKIf at first you doubt,doubt again.Wed May 21 1997 15:4215
The problem is that there is a thread lock in LIB$FIS.

In the case of the mapping of FILE2 (from the call to LIB$FIS
in FILE1), FILE2 has an initialization section (for the constructor
in "A anInstance;") that forces it to call LIB$FIS again.

Since we are in the middle of LIB$FIS already (at the call to
$IMGFIX), the flag can never be cleared to allow the constructor
to continue.  So the process is deadlocked.

This fails in the CXX case because it takes advantage of
the LIB$INITIALIZE more than most languages.
So don't call LIB$FIS in a LIB$INITIALIZE procedure (or
global constructor for a CXX module).  And IPMT this.
626.2CSC32::HENNINGA rose with no thornsWed May 21 1997 16:463
    Thanks, Ken!
    
    :^)
626.3Synchronicity...GIDDAY::GILLINGSa crucible of informative mistakesWed May 21 1997 23:224
  See also CLT::RTL note 965 for a similar issue involving LIB$FIS hanging
  when trying to activate an image containing ADA code with a LIB$INITIALIZE
  contribution. 
						John Gillings, Sydney CSC
626.4Thanks, John!CSC32::HENNINGA rose with no thornsThu May 22 1997 14:181