[mod.computers.vax] need help with VAX/VMS C

SPW2562@RITVAXC.BITNET (02/20/86)

        I've been trying to write a C program on our VAX/VMS system here at
        RIT, but have been running into some trouble.  The program is run
        from my LOGIN.COM to assign symbol names, and delete some symbols
        I don't want defined.  The assigning part works fine, but when the
        program tries deleting symols, the following occurs:

Access violation, reason mask=01, virtual address=7473B3C2, PC=00016831, PSL=03C
00000
Symbolic stack dump follows
module name     routine name                     line       rel PC    abs PC

                                                           00016831  00016831
                                                           00016502  00016502
LOGIN           main                               29      0000017A  0000077A

        Being a Unix* hack, I have no idea what this means.  (And people
        complain about Unix* error messages being cryptic.  I understand
        Unix* error messages far better than I'll ever understand this
        stuff.)  The offening line and surrounding code are here:

   ...
   lib$set_symbol("COL*OR", "WRITE SYS$OUTPUT \"\27[2J\27[H\"", tab);
   lib$set_symbol("CL*EAR", "WRITE SYS$OUTPUT \"\27[0;41;33m\27[A\"", tab);
=> lib$delete_symbol("ONE", tab);
   lib$delete_symbol("LOGOUT", tab);
   max=strlen(name)-14;
   ...

        I've run it with 'tab' as an int with value 2, and with 'tab'
        #define'd as 2, and it makes no difference.  When this function
        is called from a basic program it works fine.  Can anyone tell me
        why this is happening, and how I can correct it?
        Please respond directly to either of the below two addresses,
        as I do not subscribe to this mailing list.

*UNIX is a trademark of Bell Labs.
==============================================================================
        Steve Wall @ Rochester Institute of Technology
        Usenet: ..!rochester!ritcv!spw2562        (Fishhook)   Unix 4.2 BSD
        BITNET: SPW2562@RITVAXC                   (Snoopy)     VAX/VMS 4.2

stew%lhasa.UUCP@HARVARD.HARVARD.EDU (02/20/86)

Your problem is with string descriptors.  "Quoted Strings" in C are just
an address of an array of bytes, terminated by zero.  However, the VMS
library routines expect strings to be passed by descriptor.  See Section
9.4 of "Programming in VAX-11 C" for examples.

Stew

tihor@NYU-ACF4.ARPA (Stephen Tihor) (02/21/86)

        ... the following occurs:

Access violation, reason mask=01, virtual address=7473B3C2, PC=00016831, PSL=03C
00000

        Being a Unix* hack, I have no idea what this means.  

Being a VMS user I know to look up errors in the manual (try doing `man
bus error` on most unix systems.)  Explains says trying to through a bad 
location.  Ah ha he thinks a parameter error in:#
   ...
   lib$set_symbol("COL*OR", "WRITE SYS$OUTPUT \"\27[2J\27[H\"", tab);
   lib$set_symbol("CL*EAR", "WRITE SYS$OUTPUT \"\27[0;41;33m\27[A\"", tab);
=> lib$delete_symbol("ONE", tab);
   lib$delete_symbol("LOGOUT", tab);
   max=strlen(name)-14;
   ...

Checking the one line subroutine summaries: HELP LIB$ LIB$DELETE_SYMBOL
I see that the second parameter is the address of a longword containing the
symbol table number.  tab might contain that from the code given, but
wait:

        I've run it with 'tab' as an int with value 2, and with 'tab'
        #define'd as 2, and it makes no difference.  When this function
        is called from a basic program it works fine.  Can anyone tell me
        why this is happening, and how I can correct it?

Ah ha, you are passing a (long) the value of tab, the integer 2, which is a 
bad address as we all know instead of a (* long) such as &tab which is 
what the routine wants.

info-vax@ucbvax.UUCP (02/22/86)

In article <8602200928.AA12076@ucbvax.berkeley.edu> SPW2562@RITVAXC.BITNET writes:
>
>
>        I've been trying to write a C program on our VAX/VMS system here at
>                             . . . 
>        Being a Unix* hack, I have no idea what this means.  (And people
>   ...
>   lib$set_symbol("COL*OR", "WRITE SYS$OUTPUT \"\27[2J\27[H\"", tab);
>   ...
>        Please respond directly to either of the below two addresses,
>        as I do not subscribe to this mailing list.
>
>*UNIX is a trademark of Bell Labs.
>==============================================================================
>        Steve Wall @ Rochester Institute of Technology
>        Usenet: ..!rochester!ritcv!spw2562        (Fishhook)   Unix 4.2 BSD
>        BITNET: SPW2562@RITVAXC                   (Snoopy)     VAX/VMS 4.2

I have been following the various discussions and postings on mod.computers.vax
(and info-vax before it) for a couple of years now and have enjoyed the
relatively high technical content to be found here.  I find myself increasingly 
dismayed at the numbers of recent postings that could have been avoided by
anything more than a cursory glance at the available documentation.  The
included posting is to my mind a perfect case in point.  Heck, even the
HELP command will tell you in no uncertain terms that the strings that
are to be passed to LIB$SET_SYMBOL should be:

	'access: read only
	 mechanism: by descriptor'

in that light one could ask:

	Why was this posted?
	Why was this allowed past the moderator?

I believe that the moderator should perhaps take a more active role in
filtering out inappropriate postings of this sort.   How long would it
have taken this person to type:

	$ HELP Rtl LIB$ LIB$SET_SYMBOL

as opposed to posting the message that he generated and then caused the
rest of the world to pay for its distribution.   For all I know, he's still
waiting at his terminal with bated breath for a reply.

Perhaps the moderator already DOES filter out a lot of garbage like this, and
in that case I offer in advance profuse apologies for any aspersions that
I've cast on his/her/its character/intellect.  BUT...But...but...   you know.

There... that's a couple of screens full of vitriol.

SPW2562@RITVAXC.BITNET (02/22/86)

          Thanks to all who responded to my earlier posting.  The consensus
     seems to be that C argument passing is quite different than what
     VMS expects to get, and that it was just luck that the program didn't
     die much earlier.  Now I'll see if it works with the changes...

        Snoopy
        aka Fishhook
        Steve Wall @ Rochester Institute of Technology
        BITNET: SPW2562@RITVAXC.BITNET
        Usenet: ..!rochester!ritcv!spw2562