Linux 问题,通常是将堆栈上的值用作字符串指针。您可以从字符串中删除有问题的%s,或者,找出要包含在消息中的字符串,并将其添加到printf参数中

Linux 问题,通常是将堆栈上的值用作字符串指针。您可以从字符串中删除有问题的%s,或者,找出要包含在消息中的字符串,并将其添加到printf参数中,linux,memory,fault,Linux,Memory,Fault,(a) 除非你想要饼干屑,当然:-)谢谢你的回复。。还有一个问题,我的一个队友更新了以下行:printf(“无行更新\u编号:%s\n”);更改为:printf(“无更新行\u编号:\n”);内存故障消失。这是否只是一个误导性的问题,而para_名称的定义确实是最重要的issue@EB:这些都是错误,它们同样可能导致崩溃,正如paxdiablo显示的错误一样(在许多地方,您的printf()格式中有%s,但没有相应的参数,例如printf(“SQL Select在-get_update_time

(a) 除非你想要饼干屑,当然:-)

谢谢你的回复。。还有一个问题,我的一个队友更新了以下行:printf(“无行更新\u编号:%s\n”);更改为:printf(“无更新行\u编号:\n”);内存故障消失。这是否只是一个误导性的问题,而para_名称的定义确实是最重要的issue@EB:这些都是错误,它们同样可能导致崩溃,正如paxdiablo显示的错误一样(在许多地方,您的
printf()格式中有
%s
,但没有相应的参数,例如
printf(“SQL Select在-get_update_timestamp:%s\n”中出错“
-您需要修复所有错误)。涉及Oracle。任何问题都可能出错。运行
#define PROGRAM  "n377wlocgeo"    /* name of this program */

#define USERNAME "/"               /* ORACLE username */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>


   /* Include the ORACLE communication Area, a structure through which
   ORACLE makes additional runtime Status available to the program
   The ORACA=YES must be specified to enable use of oraca */

   EXEC SQL INCLUDE ORACA;
   EXEC ORACLE OPTION (ORACA=YES);

   EXEC SQL INCLUDE SQLCA;


/*---------------------------------------------------------------------------
 WORKING STORAGE */

/* GLOBAL EXTERNAL VARIABLES */


char *ptr;                 /* pointer for record layout */
char timestamp[26] = "\0"; /* current date and time */


/* Counters */
int   rec_err_ctr = 0;
int   cnt_rec = 0;

long  update_no_ctr = 0;
long  update_geo_ctr = 0;

long  update_no_pr_ctr = 0;
long  update_no_us_ctr = 0;

int   no_fetch_rec_ctr = 0;
int   geo_fetch_rec_ctr = 0;

int   commit_ctr = 0;


int  ws_err_sqlcode;
char para_name[25];         /* hold for displaying what paragraph abended */
char err_para_name[25];     /* hold for displaying what paragraph abended */
char abend_msg[240];


/*Pgm Control Vars */

char  error_in_job = 'N';
char  no_fetch_ended = 'N';
char  geo_fetch_ended = 'N';
char  clear_psl_cd[12];



 /* UNIX ENVIRONMENT VARIABLES  */
char debug[2];

 /* Function delarations */
 void initpara();        /* connect to Oracle  */
 void get_env_vars();    /* get the unix environment variables into C program */
 void get_timestamp();   /* get the date and time from the system */

 void connect_oracle();
 void disconnect_oracle();

 void get_update_timestamp();

 void end_transaction();
 void error_routine();
 void echofields();           /* for debugging, echo all fields parsed */

 void no_geo_cursor_process();
 void geo_cursor_process();
 void sql_no_update();
 void sql_geo_update();
 void sql_no_pr_update();
 void sql_no_us_update();



EXEC SQL BEGIN DECLARE SECTION;


 varchar      hv_psl_cd[12];
 varchar      hv_rec_udt_ts[20];
 varchar      hv_geo_cny_cd[03];
 varchar      hv_geo_psl_cd[12];
 varchar      hv_geo_typ_cd[4];
 varchar      hv_cny_cd[03];


/* Cursor to set defaults for countries with no geo classification */
 EXEC SQL DECLARE NO_GEO_CUR CURSOR FOR
      SELECT   CNY_CD
              ,PSL_CD
      FROM TDLOCTN_BASE
      WHERE CNY_CD NOT IN ('US', 'PR')
          AND GEO_ARA_PSL_CSF_CD is null
      GROUP BY CNY_CD, PSL_CD
      ORDER BY CNY_CD, PSL_CD;


  EXEC SQL DECLARE GEO_CUR CURSOR FOR
      SELECT GEO_CNY_CD,
             GEO_PSL_CD,
             GEO_TYP_CD
      FROM TDLOC_GEO_CD_EXT
      GROUP BY GEO_CNY_CD,GEO_PSL_CD,GEO_TYP_CD
      ORDER BY GEO_CNY_CD,GEO_PSL_CD;


EXEC SQL END DECLARE SECTION;

/*----------------------------------------------------------
 PROCEDURE DIVISION
------------------------------------------------------------
   MAINLINE */

/*------------------------------------------------------------*/
 int main(int argc, char **argv)

   {


      printf ("Starting");

      get_timestamp();

      printf("PGM BEGIN DATE/TIME : %s \n", timestamp );

     initpara();

     if ( strcmp(debug, "Y") == 0 )
           get_timestamp();
           printf("main while loop: %s\n", timestamp);

      /* get max rec_udt_tms for cursor process */
      get_update_timestamp();

      /* open the cursor and fetch all rows for defaults  . */

      no_geo_cursor_process();

     if ( error_in_job == 'Y' )
          exit(2);
      else
          exit(0);
   }


/*------------------------------------------------------------*/
  void get_timestamp()

  {
    strcpy(para_name, "Para = get_timestamp");
    if ( strcmp(debug, "Y") == 0 )
           printf("function: get_timestamp\n");

    struct tm *tm_now;
    time_t secs_now;

/no_geo_cursor

    EXEC SQL
        SELECT TRUNC(MAX(REC_UDT_TS))
               INTO :hv_rec_udt_ts
         FROM TDLOCTN_BASE;



    if ( sqlca.sqlcode == 0 )
        printf("CHAR  %-25s : %s \n", "hv_rec_udt_ts", hv_rec_udt_ts.arr);
    else
       {
         printf("SQL Select Error in - get_update_timestamp: %s\n");
         strcpy(abend_msg, sqlca.sqlerrm.sqlerrmc);
         printf("SQL ERROR CODE: %d\n", sqlca.sqlcode);
         printf("SQL ERROR MSG: %s\n", abend_msg);
         error_routine();
        }
  }

 void no_geo_cursor_process ()

   {
     strcpy(para_name, "Para = no_geo_cursor_process");
     if ( strcmp(debug, "Y") == 0 )
          printf("function: no_geo_cursor_process\n");

     EXEC SQL
        OPEN NO_GEO_CUR;

     if ( sqlca.sqlcode == 0 )
        printf("Cursor Opened: %s\n");
     else
        {
         printf("SQL Open Error in - no_geo_cursor_process: %s\n");
         strcpy(abend_msg, sqlca.sqlerrm.sqlerrmc);
         printf("SQL ERROR CODE: %d\n", sqlca.sqlcode);
         printf("SQL ERROR MSG: %s\n", abend_msg);
         error_routine();
        }
char para_name[25];
strcpy(para_name, "Para = no_geo_cursor_process");
//                          1         2
//                 12345678901234567890123456789 (one extra for the NULL).
printf("SQL Select Error in - get_update_timestamp: %s\n");
printf("Cursor Opened: %s\n");