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

Conference turris::c_plus_plus

Title:C++
Notice:Read 1.* and use keywords (e.g. SHOW KEY/FULL KIT_CXX_VAX_VMS)
Moderator:DECCXX::AMARTIN
Created:Fri Nov 06 1987
Last Modified:Thu Jun 05 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3604
Total number of notes:18242

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

    Dear all,
    
    Appreciate your input on this problem.  Suspect the problem isn't with
    C++, but wanted you to see this (in case it is CRTL-related in some
    obscure way).  Am also cross-posting this in VMSNOTES conference.
    
    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.
    
    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
3583.1CSC64::BLAYLOCKIf at first you doubt,doubt again.Wed May 21 1997 16:224
Answered in VMSnotes.  Basically, the "A anInstance" call
calling LIB$FIS is interfered with because we are already
in LIB$FIS at the time.
3583.2CSC32::HENNINGA rose with no thornsWed May 21 1997 17:1524
    Here's Ken's reply in VMSNOTES:
    
              <<< VAXAXP::NOTES$:[NOTES$LIBRARY]VMSNOTES.NOTE;1 >>>
               -< VAX and Alpha VMS - Digital Internal Use Only >-
================================================================================
Note 626.1            LIB$FIND_IMAGE_SYMBOL hangs in V7.1?                1 of 2
CSC64::BLAYLOCK "If at first you doubt,doubt again." 15 lines  21-MAY-1997 14:42
--------------------------------------------------------------------------------

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.