Menu

GT.M Shared Library Problem

Help
2004-03-06
2004-03-17
  • Michael Zacharias

    I've created a Perl module that wraps the gtm_* C functions in the GTM shared library.  I am having a problem calling the gtm_ci function inside of a loop. 

    The basic premise of my program is that it creates a Perl object (Stock), serializes the object, then uses my GT.M module to save the serialized data in GT.M.  The program exits half-way through the loop with the error:

    %GTM-F-KILLBYSIGSINFO2, GT.M process 11946 has been killed by a signal 11 at address 0x4207A703

    The first few symbols are serialized and stored correctly, but for some reason the program is failing.  Any ideas would be appreciated...

    __CODE__

    GTM::Lite    #Perl module to wrap libgtm
    ...
    #include "/usr/local/gtm/gtmxc_types.h"
    #define BUF_LEN 1024

    gtm_status_t my_gtm_init() {
        gtm_status_t status = gtm_init();
        return status;
    }

    gtm_status_t my_gtm_ci(gtm_char_t* c_call_name, gtm_char_t* retval) {
    gtm_status_t status;

        status = gtm_ci(c_call_name, retval);
        return status;
    }

    void my_gtm_zstatus () {
        Inline_Stack_Vars;
        gtm_char_t* msgbuf[BUF_LEN];
        SV* perl_sv;
       
        gtm_zstatus(msgbuf, BUF_LEN);
        perl_sv = perl_get_sv(msgbuf,FALSE);
        Inline_Stack_Reset;
        Inline_Stack_Push(perl_sv);
        Inline_Stack_Done;
    }

    gtm_status_t my_gtm_exit() {
       gtm_status_t status = gtm_exit();
       return status;
    }
    __END__

    #main perl program...

    my $status = gtm_init();
    print gtm_zstatus() . "\n" if $status;
    print "Initialized GT.M.  Returned status: $status\n";

    foreach my $symbol (qw/IBM RHAT WEBM SCAI CM.TO COST C SPY DIA QQQ MANU ORCL PSFT SY COMS DELL HPQ INTC TMTA YHOO EBAY AMZN/) {
        print "Adding $symbol...\n";
        my $stock = new Stock();
        $stock->symbol($symbol);
        $stock->update();
        my $rec = $stock->serialize();
        my $status = gtm_ci('stock_save',$rec);
        if ($status) { print "error: " . gtm_zstatus(). "\n" };
    }

    $status = gtm_exit();
    print gtm_zstatus() . "\n" if $status;
    print "Exiting GT.M.  Returned status: $status\n";

    calltab.ci
    stock_save    : void            save^stock(I:gtm_char_t*)

    __M Code__
    stock
    Q;
    ;
    save(rec)
    ;S $ZTRAP="W !,$ZSTATUS,! Q"
    ;W "In GT.M.  rec = "_rec,!
    N sym,comp,exch,open,high,low,close,vol,chng,pchng,ltd
    S sym=$P(rec,"|",1)
    S comp=$P(rec,"|",2)
    S exch=$P(rec,"|",3)
    S open=$P(rec,"|",4)
    S high=$P(rec,"|",5)
    S low=$P(rec,"|",6)
    S close=$P(rec,"|",7)
    S vol=$P(rec,"|",8)
    S chng=$P(rec,"|",9)
    S pchng=$P(rec,"|",10)
    S %DT=$P(rec,"|",11) D %CDN^%H S ltd=%DAT
    L +^STOCK
    S ^STOCK(sym)=comp_"|"_exch
    S ^STOCK(sym,1)=open_"|"_high_"|"_low_"|"_close_"|"_vol_"|"_chng_"|"_pchng_"|"_ltd
    L -^STOCK
    Q

     
    • Nergis Dincer

      Nergis Dincer - 2004-03-09

      Hi Michael,
      We'd need some information from you in order to analyze this issue:
      - Which version of GT.M are you using?
      - Have you built it yourself, or downloaded the build from SourceForge?
      - Could you please send us the output of:
        > gdb $gtm_dist/mumps core
        (gdb) x/10i 0x4207A703
      - Also please send any GTM*.ZSHOW* files that were created.

      Also what is your OS version?

      Thanks,
      Nergis

      - and, what

       
    • Michael Zacharias

      I am using GTM V44003 which I downloaded from Sorceforge (i.e. I did not build it myself).  I am using Redhat 9.0 and Redhat 7.3.

      The errors did not produce a core file or any other error files.

      I have rebuilt my Stock.pm class as I believe the problem I was experiencing was due to the type conversions needed to pass data between the gtm types and perl SV types.  The loop works now, but IO seems to be an issue. My Stock.pm class uses the Finance::YahooQuote module to retrieve stock quotes.  When I run the program without saving the data to GT.M, everything works fine.  But when I include the call to save the serialized class, not all symbols are successfully retrieved from Yahoo.  Also, I have to reset the terminal after every time I run the program.  Any ideas on this???

      Full source code is available upon request...

       
    • Michael Zacharias

      Can anyone tell me what exactly happens in the gtm_init and gtm_exit functions???

      Michael

       
    • Malleswara Rao P

      Hi Michael,
      The gtm_init() and gtm_exit() are the creators and destroyers of the GT.M run-time environment.
      The gtm_init() initializes the GT.M run-time environment by creating the run-time M stack, and setting up an initial base frame (call-in frame) at the level 1 (i.e. $ZLEVEL = 1) so that a called-in routine (i.e. called via gtm_ci()) executes on top of it. This routine just sets up the this base frame and returns.
      The gtm_exit() is the opposite of gtm_init(). It destroys the entire run-time stack by unconditionally unwinding the entire stack and also closes all open databases.
      The file sr_unix/gtmci.c contains the definitions of these interface functions.

      Regarding your original problem, it is difficult to investigate without more information. core would be helpful. Is the coresizelimit small enough on the system that it couldn't generted core? Can you reproduce it by bumping up this limit and see if it generates core? or is it possible to narrow down the problem to a simple reproducible case?

      Please verify that the data passed to gtm_ci() match exactly in type with the parameters specified in the *.ci file and also the strings are null-terminated. The my_gtm_zstatus() wrapper seems to declare gtm_char_t *msg[] while it's probably intended to be gtm_char_t msg[] ?

      thanks
      -malli

       

Log in to post a comment.