[an error occurred while processing this directive]

HP OpenVMS Systems

Ask the Wizard
» 

HP OpenVMS Systems

OpenVMS information

» What's new on our site
» Upcoming events
» Configuration and buying assistance
» Send us your comments

HP OpenVMS systems

» OpenVMS software
» Supported Servers
» OpenVMS virtualization
» OpenVMS solutions and partners
» OpenVMS success stories
» OpenVMS service and support
» OpenVMS resources and information
» OpenVMS documentation
» Education and training

Quick Links

» Non-javascript page
» Ask the Wizard
» OpenVMS FAQ

Test Drive OpenVMS

» OpenVMS I64 test drive
» Java test drive

Other information resources available to you include:

» OpenVMS freeware
» ECO kits, software and hardware support, prior version support
» Alpha SRM, ARC, and AlphaBIOS firmware updates
» ENCOMPASS - HP user group
» OpenVMS software downloads, OpenVMS freeware CD-ROM
» OpenVMS firmware locations
» DECconnect passive adaptor charts
» Cables reference guide
» MicroVAX console commands
» OpenVMS student research

Select a topic below to see Questions Frequently Asked by partners

» Using the online documentation library(installing BNU from the asap SDK)
» Global sections(how to create and use.)
» xx$CREATE_BUFOBJ system service(usage)
» Ethernet address(methods of determination)
» Shareable images(cookbook approach to creating one)
» Sharing data/code at absolute addresses(a guide with examples)
» Determining the Alpha microprocessor
» Using GETSYI to get hardware status

Evolving business value

» Business Systems Evolution
» AlphaServer systems transition planning
» Alpha RetainTrust program

Related links

» HP Integrity servers
» HP Alpha systems
» HP storage
» HP software
» HP products and services
» HP solutions
» HP support
disaster proof
HP Integrity server animation
HP Integrity server animation
Content starts here

Ask the Wizard Questions

Debug C application

The Question is:

I am writing an application in 'C' that utilizes the SMG$ screen management
functions. One of the functions I am calling is SMG$READ_STRING to obtain
a string of characters from the user. The function seems to work ok, but the
user prompt always appears to start from the edge of the screen instead of the
virtual display edge. Also , at some point AFTER the function returns successfully,
the program will abort with an access violation. This can occur hundreds of lines
later in the program. If I remove the call to this function. Everything works fine. Are
calls to SMG$ asynchronous? Is this a known problem with SMG?
>the user prompt always appears to start from the edge of the screen instead of
>the virtual display edge

      This suggests that READ_STRING doesn't know which virtual display to
    place the prompt in. You should use one of the "SET CURSOR" functions
    to position the cursor in the target display, then, when calling
    READ_STRING, make sure you specify the virtual display in the call
    (it's the 10th argument).

>at some point AFTER the function returns successfully,
>the program will abort with an access violation. This can occur hundreds of
>lines later in the program. If I remove the call to this function. Everything
>works fine. Are calls to SMG$ asynchronous?

    SMG calls are not asynchronous. Without the details of the ACCVIO
    message, I can only speculate. I'd guess that there is something wrong
    with your argument list which is causing READ_STRING to corrupt memory
    locations outside your declared bounds. For example, if the read buffer
    is declared shorter than the maximum length you have specified.

    It would not be unusual for such a memory corruption to result in an
    ACCVIO "hundreds of lines" away.

    I'd advise you carefully check your argument list. Make sure everything
    is correct in position, data type and passing mechanism.

>Is this a known problem with SMG?

    No, but it may be a "known problem" in programming in general,
    *particularly* programming on C ;-) Note - NOT a compiler bug, a
    programmer bug!. Consider:

      void routine()
      { char astring[10];
        $DESCRIPTOR(string_descr,astring)
      ...
      stat=SMG$READ_STRING(&kbd,&string_descr,&prompt,&20,0,0,0,0,0,&display);

    Now, since "astring" is allocated on the stack, just below the call
    frame, if anything writes beyond the end of the array, it will
    overflow into the call frame. This won't be "discovered" until you
    return from the routine. If you're lucky, it will cause an ACCVIO.
    Make sure everything agrees about the declarations of all data objects.

    For a better guess as to what's going on, we'd need to see the exact
    text of the ACCVIO and the code for the call to SMG$READ_STRING. Even
    better, if you can cut your program down to a small example which
    demonstrates the problem (say 50 lines maximum).



The Answer is: