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

Conference turris::decc

Title:DECC
Notice:General DEC C discussions
Moderator:TLE::D_SMITHNTE
Created:Fri Nov 13 1992
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2212
Total number of notes:11045

2159.0. "function "get confused" on OpenVMS V7.1 / kit with new DECC$SHR.EXE available?" by TAEC::DUHAMEL (Philippe Duhamel, SISB Telecom @VBE DTN 828-5836) Wed Apr 23 1997 12:56

A C program function "get confused" when working on OpenVMS V7.1.

This function normally swaps the contents of 2 files by renaming one file into 
the other one.

Under OpenVMS V7.1, it produces 2 versions of the same file and no other file 
at all. The debug version of this executable behaves normally!

After investigating, we tried on the Open VMS V7.1 machine an OpenVMS V6.2
version of the DECC$SHR.EXE file. The failing executable worked correctly.

The ids of the DECC$SHR.EXE files are :

* OpenVMS V7.1 failing DECC$SHR.EXE :
ANALYZ A05-19
image file identification: "X07.1-3"
image file build identification: "X6C7-0040069227"
link date/time: 25-NOV-1996 21:52:49.56
linker identification: "A11-39"

* OpenVMS V6.2 good DECC$SHR.EXE :
ANALYZ A07-04
image file identification: "T06.2-05"
image file build identification: "X61Q-SSB-0000"
link date/time:  4-MAY-1995 22:34:03.13
linker identification: "A11-12"

Is there a newer version of the OpenVMS V7.1 file correcting this problem?

Thanks in advance.

Philippe Duhamel
T.RTitleUserPersonal
Name
DateLines
2159.1Code?XDELTA::HOFFMANSteve, OpenVMS EngineeringWed Apr 23 1997 13:129
   Can you post the source code to the function?

:Is there a newer version of the OpenVMS V7.1 file correcting this problem?

   (I'll assume you know about COMET and the Internet Patch area.)
   There are ECO kits out, but none of the released kits appear
   to address this particular problem.

2159.2C++ function codeTAEC::DUHAMELPhilippe Duhamel, SISB Telecom @VBE DTN 828-5836Thu Apr 24 1997 06:1375
You will find hereafter the failing C++ code.


void switch_file ( boolean_t AB_file_switch )
{
  char            VA_tmp_file[150] ;
  char            VA_tmp_name[150] ;
  char            *VA_directory ;
  int             VI_i ;

  /*
   * Switch the file and the attribut "file_name"
   */

  // search the directory
  // (standby and active directories are equal
#ifdef __VMS
  VA_directory = strrchr ( VP_standby->EA_file_name, ']' ) ;
#else
  VA_directory = strrchr ( VP_standby->EA_file_name, '/' ) ;
#endif // __VMS

  for ( VI_i = 0 ; VI_i <= VA_directory - VP_standby->EA_file_name ; VI_i ++  )
    VA_tmp_file[VI_i] = VP_standby->EA_file_name[VI_i] ;
  sprintf(VA_tmp_file, "%sSS7_RULES.TMP", VA_tmp_file ) ;

  // mv standby tmp
  if ( AB_file_switch )
    rename ( VP_standby->EA_file_name, VA_tmp_file ) ;
  strcpy ( VA_tmp_name, VP_standby->EA_file_name ) ;

  // mv active standby
  if ( AB_file_switch )
    rename ( VP_active->EA_file_name, VP_standby->EA_file_name ) ;
  strcpy ( VP_standby->EA_file_name, VP_active->EA_file_name ) ;

  // mv tmp active
  if ( AB_file_switch )
    rename ( VA_tmp_file, VP_active->EA_file_name ) ;
  strcpy ( VP_active->EA_file_name, VA_tmp_name ) ;
}


cond_value_t ss7_mgt_gtt_switch (
         boolean_t        file_switch
     )
{
  TP_set_of_rules VP_tmp_set ;

  /*
   * Initialize the GTT (if necessary)
   */
  if ( !VB_gtt_initialized )
    ss7_mgt_gtt_initialize ( CI_FROM_OTHER ) ;

  /*
   * Switch the file (filename and/or not file)
   */
  switch_file ( file_switch ) ;

  /*
   * Switch the pointer
   */
  VP_tmp_set = VP_standby ;
  VP_standby = VP_active ;
  VP_active = VP_tmp_set ;

  /*
   * Switch the global section pointers
   */
  VP_stb_global_section = VP_standby->EP_gtt_gs ;
  VP_act_global_section = VP_active->EP_gtt_gs ;

  return ( SS7$_NORMAL ) ;
}
2159.3WIBBIN::NOYCEPulling weeds, pickin&#039; stonesThu Apr 24 1997 09:1140
Some comments...

>  for ( VI_i = 0 ; VI_i <= VA_directory - VP_standby->EA_file_name ; VI_i ++  )
>    VA_tmp_file[VI_i] = VP_standby->EA_file_name[VI_i] ;

This could be written more simply as
   memcpy(VA_tmp_file, VP_standby->EA_file_name,
		(VA_directory - VP_standby->EA_file_name + 1));


>  sprintf(VA_tmp_file, "%sSS7_RULES.TMP", VA_tmp_file ) ;

This is skating pretty close to the edge -- you're both reading and writing
VA_tmp_file in this call.  I suspect it is supported, but it makes me
uncomfortable.  (If you had sprintf(X, "A%sBCDEF", X) it would definitely
not be supported.)  This could be written more simply as
   strcat(VA_tmp_file, "SS7_RULES.TMP");


You don't check the status of any of your rename() calls.  I suspect the
real problem is that one or more of them is failing.  Without the status
it's hard to know why.


The interleaved rename() and strcpy() calls were confusing, because I didn't
at first see the difference between VA_tmp_file (which is the file name to
use as an intermediate in the rename() calls) and VA_tmp_name (which is just
a buffer used for swapping name strings).  It would have been clearer to me
if you had written
  // swap the actual files  standby->tmp; active->standby; tmp->active
  if ( AB_file_switch ) {
    rename ( VP_standby->EA_file_name, VA_tmp_file ) ;
    rename ( VP_active->EA_file_name, VP_standby->EA_file_name ) ;
    rename ( VA_tmp_file, VP_active->EA_file_name ) ;
  }

  // swap the name strings.
  strcpy ( VA_tmp_name, VP_standby->EA_file_name ) ;
  strcpy ( VP_standby->EA_file_name, VP_active->EA_file_name ) ;
  strcpy ( VP_active->EA_file_name, VA_tmp_name ) ;
2159.4Comments...XDELTA::HOFFMANSteve, OpenVMS EngineeringThu Apr 24 1997 12:2824
   In addition to checking the rename status...

:  char            VA_tmp_file[150] ;
:  char            VA_tmp_name[150] ;

   OpenVMS file specifications can currently be up to 255 characters,
   and this value may increase.  (NAM$C_MAXRSS is one constant in this
   area.)

:#ifdef __VMS
:  VA_directory = strrchr ( VP_standby->EA_file_name, ']' ) ;
:#else
:  VA_directory = strrchr ( VP_standby->EA_file_name, '/' ) ;
:#endif // __VMS

   OpenVMS will accept UNIX-format file specifications.
   Also, the "]" and the ">" are the directory end delimiters.

:You will find hereafter the failing C++ code.

   Also see TURRIS::C_PLUS_PLUS -- though this doesn't immediately
   look like it's a C vs C++ issue...

2159.5DECC::OUELLETTEmudseason into blackfly seasonThu Apr 24 1997 21:125
Also, I'd use mumble$PARSE to pick apart the file name.
You may not see a ] or a > in a complicated file name like DECC::foo.bar or
sys$library:decc$rtldef.tlb.  This all gets much more complicated when
VMS adds funny filenames with funny characters in them and then you
really need to use the $PARSE function to get it right.
2159.6Code improved, but DECC$SHR.EXE problem remainsTAEC::DUHAMELPhilippe Duhamel, SISB Telecom @VBE DTN 828-5836Fri Apr 25 1997 05:487
Thank you all three for your contribution to our code improvement! Your changes 
suggestions have been implemented. Unfortunately they did not solve the problem.

I was not able to find more information in the C++ conference.

Now its seems that the problem is on the DECC$SHR.EXE side, as the OpenVMS V6.2 
version of this file corrects the behaviour we found with the OpenVMS V7.1 one.
2159.7Tools To Localize Fault...XDELTA::HOFFMANSteve, OpenVMS EngineeringFri Apr 25 1997 12:1416
   Did you work through the new code in the debugger, to determine more
   about what is going on in the application?  (I will assume you are
   now checking and reporting errors in the completion status from the
   rename operations, and any other operations that return completion
   status values.)

   Have you considered using full security auditing to track the activity
   of the programs?  And have you considered using the XQP monitoring
   during a program run?  (Use "SET WATCH/CLASS=ALL FILE" to enable, and
   use "SET WATCH/CLASS=NONE FILE" to disable.  Requires CMKRNL.)

   Also consider replacing the rename operation with the lib$rename_file
   RTL call -- this technique will tend to either eliminate or implicate
   the DECC$SHR as the culprit.