#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2009
    Location
    vizag
    Posts
    3
    Rep Power
    0

    Exclamation MQ C Utilities 64 Bit Issues


    Hello all, I have a problem with MQ utilities coded C running on HPUX 64 bit box, when i try to run the utility i get

    Code:
    Syncpoint 0 Interval Encoding CodedCharSetId EOF = 1 Starting search loop... MQGET RC = 0 Found batch MQGET RC = 0 Starting read loop... MQGET RC = 2080 Resizing buffer to 30584 MQGET(2) RC = 0 messageLength = 30584 Memory fault(coredump)
    I have tried compiling the utilities on server itself... using the command options

    Code:
    CCOPTS = -Aa -D_HPUX_SOURCE
    When i try to run with -Dd64 i get errors please help
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,365
    Rep Power
    1870
    If this is the first time you've tried compiling a program originally written for a 32-bit machine using a 64-bit compiler, then expect a whole host of assumptions to be broken.

    There is NO simple fix except to go through the code with a fine tooth comb to find all the places where the original programmer made assumptions about the machine word size or memory layout.

    For example,
    Code:
    struct foo {
        char a;
        int b;
    };
    - the amount of padding space between a and b may have increased from 3 bytes to 7 bytes.
    - the size of b may have increased from 4 bytes to 8 bytes.

    This is just one of many kinds of similar problems where assuming a particular word size of memory layout will suddenly break when compiled on another architecture.

    Remember, debugging on the old program stopped when the program stopped crashing, not when it was bug-free.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2009
    Location
    vizag
    Posts
    3
    Rep Power
    0
    Originally Posted by salem
    If this is the first time you've tried compiling a program originally written for a 32-bit machine using a 64-bit compiler, then expect a whole host of assumptions to be broken.

    There is NO simple fix except to go through the code with a fine tooth comb to find all the places where the original programmer made assumptions about the machine word size or memory layout.

    For example,
    Code:
    struct foo {
        char a;
        int b;
    };
    - the amount of padding space between a and b may have increased from 3 bytes to 7 bytes.
    - the size of b may have increased from 4 bytes to 8 bytes.

    This is just one of many kinds of similar problems where assuming a particular word size of memory layout will suddenly break when compiled on another architecture.

    Remember, debugging on the old program stopped when the program stopped crashing, not when it was bug-free.
    Thats bad because we have over 1000 lines per file and 6 .c files and the worst part is I started learning programming with Java..

    the error i get when i compile is

    Code:
    ld: Mismatched ABI for -lmqm, found /opt/mqm/lib/libmqm.so
    Do that mean 64 bit version is missing?

    I found out that in both our test and production servers the version is

    Code:
     HP Bundiled for Integrity Servers B3910B A.06.12 [Oct 11 2006]
    Is this right? or should there be another c running on the 64 bit machine?

    What you said is correct we are really facing memory allocation issues... since i can understand it i can make modification to the code

    what do you suggest? if there are declarations

    Code:
    #define TRAFFIC_COP_MAX_REQUEST 128
    Code:
    #define TRAFFIC_COP_MAX_REPLY 144+28+20+16+12+9999
    should i increase or decrease the numbers?
  6. #4
  7. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,365
    Rep Power
    1870
    > Thats bad because we have over 1000 lines per file and 6 .c files and the worst part is I started learning programming with Java..
    To be honest, you need to hire a competent C programmer to do this - specifically someone with prior experience of porting s/w to different machine architectures.

    Since you seem to be using commercial tools, do you have a support contract for this s/w?

    the error i get when i compile is
    Code:
    ld: Mismatched ABI for -lmqm, found /opt/mqm/lib/libmqm.so
    Do that mean 64 bit version is missing?
    Quite possibly.
    You can check what machine a library is compiled for using the file command, eg.
    Code:
    $ file /lib/libtinfo.so.5.9 
    /lib/libtinfo.so.5.9: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, stripped

    what do you suggest? if there are declarations
    Code:
    #define TRAFFIC_COP_MAX_REQUEST 128
    Code:
    #define TRAFFIC_COP_MAX_REPLY 144+28+20+16+12+9999
    should i increase or decrease the numbers?
    No, you shouldn't change these at all.
    For example, the max message length is a contract between the sender and the receiver. Not only do you have to stop the 64-bit version from crashing, you also have to make sure it still works with the rest of the 32-bit world around you.

    Start with this simple program, and compare results on both machines.
    Code:
    #include <stdio.h>
    #include <stddef.h>
    
    struct foo {
      char  a;
      short b;
      int   c;
      long int d;
      float e;
      double f;
    };
    
    #define INFO(x) printf("Offset of %s is %d, size is %d\n", \
        #x, (int)offsetof(struct foo,x), (int)sizeof(var.x))
    main ( ) {
      struct foo var;
      INFO(a);
      INFO(b);
      INFO(c);
      INFO(d);
      INFO(e);
      INFO(f);
      return 0;
    }
    
    $ ./a.out 
    Offset of a is 0, size is 1
    Offset of b is 2, size is 2
    Offset of c is 4, size is 4
    Offset of d is 8, size is 8
    Offset of e is 16, size is 4
    Offset of f is 24, size is 8
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2009
    Location
    vizag
    Posts
    3
    Rep Power
    0
    Originally Posted by salem
    > Thats bad because we have over 1000 lines per file and 6 .c files and the worst part is I started learning programming with Java..
    To be honest, you need to hire a competent C programmer to do this - specifically someone with prior experience of porting s/w to different machine architectures.

    Since you seem to be using commercial tools, do you have a support contract for this s/w?


    Quite possibly.
    You can check what machine a library is compiled for using the file command, eg.
    Code:
    $ file /lib/libtinfo.so.5.9 
    /lib/libtinfo.so.5.9: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, stripped


    No, you shouldn't change these at all.
    For example, the max message length is a contract between the sender and the receiver. Not only do you have to stop the 64-bit version from crashing, you also have to make sure it still works with the rest of the 32-bit world around you.

    Start with this simple program, and compare results on both machines.
    Code:
    #include <stdio.h>
    #include <stddef.h>
    
    struct foo {
      char  a;
      short b;
      int   c;
      long int d;
      float e;
      double f;
    };
    
    #define INFO(x) printf("Offset of %s is %d, size is %d\n", \
        #x, (int)offsetof(struct foo,x), (int)sizeof(var.x))
    main ( ) {
      struct foo var;
      INFO(a);
      INFO(b);
      INFO(c);
      INFO(d);
      INFO(e);
      INFO(f);
      return 0;
    }
    
    $ ./a.out 
    Offset of a is 0, size is 1
    Offset of b is 2, size is 2
    Offset of c is 4, size is 4
    Offset of d is 8, size is 8
    Offset of e is 16, size is 4
    Offset of f is 24, size is 8



    Ok i found some lines containing variables, and the point is 64 bit environment will not communicate with 32 bit.... and the Max message length is used within 2 c files to communicate I can change both if needed,

    Code:
     typedef char SLHCHAR;               /*  Define my own characters    */
    
     typedef SLHCHAR SLHCHAR1[1];        /*  Single character values     */
     typedef SLHCHAR SLHCHAR4[4];        /*  Four character values       */
     typedef SLHCHAR SLHCHAR7[7];        /*  Seven character values      */
     typedef SLHCHAR SLHCHAR8[8];        /*  Eight character values      */
     typedef SLHCHAR SLHCHAR12[12];      /*  12 character values         */
     typedef SLHCHAR SLHCHAR28[28];      /*  28 character values         */
     typedef SLHCHAR SLHCHAR48[48];      /*  48 character values         */
    and some sort of array is being declared...

    Code:
     typedef struct tagSLHFQDB {
        SLHCHAR4   StrucId;           /*  Structure identifier           */
        SLHCHAR4   Version;           /*  Structure version identifier   */
        SLHCHAR4   Length;            /*  Structure length               */
        SLHCHAR12  ProgramResponding; /*  Program responding to FQRQ     */
        SLHCHAR4   ResponseCode;      /*  Response code from program     */
        SLHCHAR48  QueueName;         /*  Queue name                     */
        SLHCHAR48  ReplyToQName;      /*  ReplyTo Queue name             */
        SLHCHAR48  QueueMgrName;      /*  Queue manager name             */
        SLHCHAR1   UseSyncpoints;     /*  Use Syncpoints? Y/N            */
        SLHCHAR7   SyncpointInterval; /*  # of records in a syncpoint    */
        SLHCHAR8   Format;            /*  MQFormat field                 */
        SLHCHAR1   FileOpenMode;      /*  File Open Mode Text/Binary     */
        SLHCHAR1   Persistence;       /*  MQPersistence field  Y/N/D     */
        SLHCHAR1   Priority;          /*  MQPriority field 0-9, D        */
        SLHCHAR1   AddEOFMessage;     /*  Add EOF message Y/N            */
        SLHCHAR1   AddRFH2YN;         /*  Add RFH2 to message Y/N        */
        SLHCHAR1   OvrEncodingYN;     /*  Override Encoding/CCSID Y/N    */
        SLHCHAR1   OvrExpiryYN;       /*  Override Expiry Y/N            */
        SLHCHAR1   QTOFProcessingYN;  /*  Special Handling for QtoF  Y/N */
        SLHCHAR1   PrcssSnglMsgYN;    /*  Process Single Message Y/N     */
        SLHCHAR1   SendMDN;           /*  Send MDN Y/N                   */
        SLHCHAR48  FilePrefix;        /*  File Prefix string             */
     } SLHFQDB;
    will compiling the code with +DD64 solve the problem... i will also post the output of

    Code:
    what `which cc`
    shortly

IMN logo majestic logo threadwatch logo seochat tools logo