Link to home
Start Free TrialLog in
Avatar of Tim Van der Stighelen
Tim Van der Stighelen

asked on

Need help compiling ansi c program on RedHat unix

Hi,

We are moving from a HP-UX system to a Linux RedHat system.

We have some ansi C / proC programs running and I have troubles to get them compiled on the new system.

To get it compiled I had to remove some flags and commands because they are not available on the new compiler like:
gcc +s option
-D_HPUX_API_LEVEL=20040821 option
chatr +s enable ctpdb
-lsql11 became -lsqlplus

One error remains but I get it compiled eventually:
ctp_str.h:69:5: error: unknown type name ‘BOOLEAN’
     BOOLEAN ctp_maintain_gcns;

Eventually I get them compiled, but they crash every time the programs use a function that is extern (so not in the own *.pc member)
e.g. extern void ctp_gen_setup_test_flags
At runtime it just gives "memory fault"
Probably because I have no alternative for the chatr command and the +s flag...

Please advice on how I can get it compiled and running so that it is able to call the functions in external member.

I attach the original makefile that compiles the code on HP-UX, but not on linux, so that you can advice how the new makefile should look like.

Regards and thank you in advanced,
Tim
Avatar of Tim Van der Stighelen
Tim Van der Stighelen

ASKER

Ok fixed the ctp_str.h:69:5: error: unknown type name ‘BOOLEAN’ error by adding this to ctp_str.h:

#define BOOLEAN int
#define TRUE 1
#define FALSE 0

So only the external calling issue remains...
Avatar of sarabande
the makefile was not attached. please attach it between code tags.

extern void ctp_gen_setup_test_flags

void type is only valid as return value of a function prototype. so i assume the expression was not complete.

if a function is declared as extern, you need a second c source where the function is defined (... has an implementation). then both c files must be compiled and linked together. if the function comes from an external library, you must link against the library. also you should make sure that the ansi-c compiler was used for both your source and the object file or object library where the function was implemented. if one of those was compiled with a c++ compiler, it would not work. at least not without some wrappers that are matching c++ mangled function names to pure c names.

Sara
#-----------------------------------------------------------------------------
#
# Makefile to build the configuration transfer processes
# of the Managed Service
#
#-----------------------------------------------------------------------------


JVersion  = 8
JRE       = /opt/java${JVersion}/jre
JLib      = ${JRE}/lib/IA64N

COPTS = -D_HPUX_API_LEVEL=20040821
INCLUDES = -I/usr/include -I${MS_ROOT}/include -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/hpux
LIBRARIES = -L${MS_ROOT}/lib -L${DEV_ROOT}/lib -L${JLib}/native_threads -L${JLib}/server -L${JLib}  -L${ORACLE_HOME} -L${ORACLE_HOME}/lib
#LDFLAGS  = -L${MS_ROOT}/lib -L${ORACLE_HOME}/lib -L${JLib}/native_threads -L${MS_ROOT}/lib -L${JLib} -L${JLib}/server  -lpthread
LDFLAGS = +s -lpthread
LIBS     = -lms -lm -lc -lsql11 -ljava -lclntsh -lnet -ljvm
CFLAGS   = ${COPTS} ${INCLUDES} ${LIBRARIES}
RM       = /usr/bin/rm

#-----------------------------------------------------------------------------

#all: ctpdb ctp send_ctpdb_global_unload.sh send_ctpdb_inc_unload.sh send_ctpdb_event_unload.sh ctpdb_global.sh
all: ctpdb ctp send_ctpdb_global_unload.sh send_ctpdb_inc_unload.sh send_ctpdb_event_unload.sh ctpdb_global.sh

#-----------------------------------------------------------------------------

# ctp general routines

ctp_file_comp.o : ctp_file_comp.c ctp_types.h
	$(CC) -c ctp_file_comp.c $(CFLAGS) $(LDFLAGS) -o ctp_file_comp.o

ctp_gen.o : ctp_gen.pc ctp_types.h ctp_gen.h
	proc CHAR_MAP=STRING ctp_gen.pc INCLUDE=${MS_ROOT}/include MODE=ANSI
	$(CC) -c ${CFLAGS} ctp_gen.c ${LDFLAGS} ${LIBS} -o ctp_gen.o

#-----------------------------------------------------------------------------

# ctpdb executable 

ctpdb : ctpdb.o ctpdb_unload_x400.o   \
		ctpdb_unload_email.o  \
		ctpdb_unload_ftp.o  \
		ctpdb_unload_ot.o    \
		ctp_gen.o 
	$(CC) ctpdb.o ctpdb_unload_x400.o   \
		ctpdb_unload_email.o  \
		ctpdb_unload_ftp.o    \
		ctpdb_unload_ot.o     \
		ctp_gen.o $(CFLAGS) ${LDFLAGS} ${LIBS} -o ctpdb
		chatr +s enable ctpdb

ctpdb.o : ctpdb.pc ctp_str.h ctp_types.h ctpdb.h
	proc CHAR_MAP=STRING SQLCHECK=SEMANTICS userid=ms/msadmin1@livecopy ctpdb.pc INCLUDE=${MS_ROOT}/include MODE=ANSI
	${CC} -c ${CFLAGS} $(?:.pc=.c)

ctpdb_unload_email.o : ctpdb_unload_email.pc ctp.h ctp_types.h ctp_str.h
	proc CHAR_MAP=STRING ctpdb_unload_email.pc INCLUDE=${MS_ROOT}/include MODE=ANSI
	${CC} -c ${CFLAGS} $(?:.pc=.c)

ctpdb_unload_ftp.o : ctpdb_unload_ftp.pc ctp.h ctp_types.h ctp_str.h
	ln -f -s ${MS_ROOT}/include/ftp_elit.h .
	proc CHAR_MAP=STRING ctpdb_unload_ftp.pc INCLUDE=${MS_ROOT}/include MODE=ANSI
	${CC} -c ${CFLAGS} $(?:.pc=.c)

ctpdb_unload_x400.o : ctpdb_unload_x400.pc ctp.h ctp_types.h ctp_str.h
	proc CHAR_MAP=STRING ctpdb_unload_x400.pc INCLUDE=${MS_ROOT}/include MODE=ANSI
	${CC} -c ${CFLAGS} $(?:.pc=.c)

ctpdb_unload_ot.o : ctpdb_unload_ot.pc ctp.h ctp_types.h ctp_str.h
	proc CHAR_MAP=STRING ctpdb_unload_ot.pc INCLUDE=${MS_ROOT}/include MODE=ANSI
	${CC} -c ${CFLAGS} $(?:.pc=.c)


#-----------------------------------------------------------------------------
#
# ctp executable 

ctp : ctp.o ctp_upload_x400.o  \
		ctp_upload_ftp.o   \
		ctp_upload_email.o  \
		ctp_upload_ot.o    \
		ctp_file_comp.o    \
		ctp_gen.o
	$(CC) ctp.o ctp_upload_x400.o  \
		ctp_upload_ftp.o   \
		ctp_upload_email.o  \
		ctp_upload_ot.o    \
		ctp_file_comp.o    \
		ctp_gen.o ${CFLAGS} ${LDFLAGS} ${LIBS} -o ctp
		chatr +s enable ctp

ctp.o : ctp.c ctp.h ctp_types.h
	$(CC) -c ctp.c $(CFLAGS) $(LDFLAGS) -o ctp.o

ctp_upload_x400.o : ctp_upload_x400.c ctp.h ctp_str.h ctp_types.h
	$(CC) -c ctp_upload_x400.c $(CFLAGS) $(LDFLAGS) -o ctp_upload_x400.o

ctp_upload_ftp.o : ctp_upload_ftp.c ctp.h ctp_types.h ctp_str.h
	$(CC) -c ctp_upload_ftp.c $(CFLAGS) $(LDFLAGS) -o ctp_upload_ftp.o

ctp_upload_ot.o : ctp_upload_ot.c ctp.h ctp_str.h ctp_types.h
	$(CC) -c ctp_upload_ot.c $(CFLAGS) $(LDFLAGS) -o ctp_upload_ot.o


clean:; $(RM) -f ctp*.o ctpdb*.c ctp*.lis
clean_all:; $(RM) -f ctp*.o ctpdb*.c ctp*.lis ctp ctpdb

#-----------------------------------------------------------------------------

Open in new window


This is the original makefile that works on HP-UX

To make it compile on Linux I had to make following changes to it:
install proc (https://www.oracle.com/database/technologies/instant-client/precompiler-112010-downloads.html)
gcc +s remove option (does not exist in gcc, did exist in cc)
-lsql12 becomes -lsqlplus
ORACLE_HOME=/usr/lib/oracle/19.3/client64/lib  added
-L${DEV_ROOT}/lib becomes lib64
JVersion  = 8 in stead of 6
IA64N becomes amd64
-I$(JAVA_HOME)/include/hpux becomes -I$(JAVA_HOME)/include/linux
-I/usr/include/linux NOT added (https://stackoverflow.com/questions/26410466/gcc-linaro-compiler-throws-error-unknown-type-name-size-t)
remove chatr +s enable ctp

I think the last has to do with the fact that it crashes at runtime when calling 'extern' functions
Note: There is no chatr command. There is a chattr command. Best to avoid using chattr ever, as chattr use requires great care.

1) Provide complete output of your make run.

2) Provide complete output of what occurs when you run you executable.

(Cut/Paste output as text, rather than images.)
There is a chatr Command on HP-UX:
https://nixdoc.net/man-pages/HP-UX/man1/chatr.1.html

    chatr +s flag        Control whether the directory path list specified with
                     the LD_LIBRARY_PATH and SHLIB_PATH environment variable
                     can be used to locate shared libraries needed by the
                     program.  The two flag values, enable and disable,
                     respectively enable and disable use of the environment
                     variable.  If both +s and +b are used, their relative
                     order on the command line indicates which path list
                     will be searched first.  See the +b option.

Open in new window


1)  output of make
ms.vma1:/source/ms/ctp/ctp> make ctpdb
proc CHAR_MAP=STRING SQLCHECK=SEMANTICS userid=ms/msadmin1@rel7aws ctpdb.pc INCLUDE=/source/ms/include MODE=ANSI 

Pro*C/C++: Release 19.0.0.0.0 - Production on Thu Sep 26 08:47:45 2019
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

System default option values taken from: /usr/lib/oracle/19.3/client64/lib/precomp/admin/pcscfg.cfg

cc -c  -I/usr/include -I/source/ms/include -I/opt/java8/include -I/opt/java8/include/linux -L/source/ms/lib -L/source/ms/lib -L/lib64 -L/opt/java8/jre/lib/amd64/server -L/opt/java8/jre/lib/amd64 -L/usr1/MS/fiorano_libs/clients/c/native/lib -L/usr/lib/oracle/19.3/client64/lib -L/usr/lib/oracle/19.3/client64/lib/lib -lm -lc -lsqlplus -lclntsh -lnet -ljvm -lms -lfmq-crtl ctpdb.c ctp_str.h ctp_types.h ctpdb.h
ctpdb.c: In function do_startup:
ctpdb.c:537:9: warning: incompatible implicit declaration of built-in function strcpy [enabled by default]
         strcpy ( process_code, "2000" );
         ^
ctpdb.c: In function do_processing:
ctpdb.c:930:21: warning: incompatible implicit declaration of built-in function memset [enabled by default]
                     memset(&ctp_array[loop1], 0, sizeof (struct ctp_array_));
                     ^
ctpdb.c:1011:21: warning: incompatible implicit declaration of built-in function strcpy [enabled by default]
                     strcpy(ctp_array[loop1].unload_type,unl_type);
                     ^
ctpdb.c:1227:13: warning: passing argument 2 of action_from_message from incompatible pointer type [enabled by default]
             action_from_message ( message_number, &action );
             ^
ctpdb.c:366:13: note: expected int * but argument is of type enum action_type *
 static void action_from_message ( int message_number,
             ^
ctpdb.c: In function do_unload_action:
ctpdb.c:1471:5: warning: incompatible implicit declaration of built-in function memset [enabled by default]
     memset( unload_flags, 0, sizeof( unload_flags_str ));
     ^
proc CHAR_MAP=STRING ctpdb_unload_x400.pc INCLUDE=/source/ms/include MODE=ANSI

Pro*C/C++: Release 19.0.0.0.0 - Production on Thu Sep 26 08:47:45 2019
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

System default option values taken from: /usr/lib/oracle/19.3/client64/lib/precomp/admin/pcscfg.cfg

cc -c  -I/usr/include -I/source/ms/include -I/opt/java8/include -I/opt/java8/include/linux -L/source/ms/lib -L/source/ms/lib -L/lib64 -L/opt/java8/jre/lib/amd64/server -L/opt/java8/jre/lib/amd64 -L/usr1/MS/fiorano_libs/clients/c/native/lib -L/usr/lib/oracle/19.3/client64/lib -L/usr/lib/oracle/19.3/client64/lib/lib -lm -lc -lsqlplus -lclntsh -lnet -ljvm -lms -lfmq-crtl ctpdb_unload_x400.c ctp.h ctp_types.h ctp_str.h
In file included from ctpdb_unload_x400.c:190:0:
ctp_str.h:20:0: warning: "BOOLEAN" redefined [enabled by default]
 #define BOOLEAN int
 ^
In file included from ctp_types.h:15:0,
                 from ctpdb_unload_x400.c:189:
/source/ms/include/standard.h:66:0: note: this is the location of the previous definition
 #  define BOOLEAN MACHINE_INT
 ^
In file included from ctpdb_unload_x400.c:190:0:
ctp_str.h:21:0: warning: "TRUE" redefined [enabled by default]
 #define TRUE 1
 ^
In file included from ctp_types.h:15:0,
                 from ctpdb_unload_x400.c:189:
/source/ms/include/standard.h:72:0: note: this is the location of the previous definition
 #  define TRUE (BOOLEAN) !FALSE
 ^
In file included from ctpdb_unload_x400.c:190:0:
ctp_str.h:22:0: warning: "FALSE" redefined [enabled by default]
 #define FALSE 0
 ^
In file included from ctp_types.h:15:0,
                 from ctpdb_unload_x400.c:189:
/source/ms/include/standard.h:69:0: note: this is the location of the previous definition
 #  define FALSE (BOOLEAN) 0
 ^
ctpdb_unload_x400.c: In function ctpdb_unload_x400:
ctpdb_unload_x400.c:342:5: warning: incompatible implicit declaration of built-in function memset [enabled by default]
     memset( &whole_rec[0], 0, sizeof ( struct x400_unload_ing_str ) );
     ^
proc CHAR_MAP=STRING ctpdb_unload_email.pc INCLUDE=/source/ms/include MODE=ANSI

Pro*C/C++: Release 19.0.0.0.0 - Production on Thu Sep 26 08:47:45 2019
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

System default option values taken from: /usr/lib/oracle/19.3/client64/lib/precomp/admin/pcscfg.cfg

cc -c  -I/usr/include -I/source/ms/include -I/opt/java8/include -I/opt/java8/include/linux -L/source/ms/lib -L/source/ms/lib -L/lib64 -L/opt/java8/jre/lib/amd64/server -L/opt/java8/jre/lib/amd64 -L/usr1/MS/fiorano_libs/clients/c/native/lib -L/usr/lib/oracle/19.3/client64/lib -L/usr/lib/oracle/19.3/client64/lib/lib -lm -lc -lsqlplus -lclntsh -lnet -ljvm -lms -lfmq-crtl ctpdb_unload_email.c ctp.h ctp_types.h ctp_str.h
ctpdb_unload_email.c: In function ctpdb_unload_email:
ctpdb_unload_email.c:325:5: warning: incompatible implicit declaration of built-in function memset [enabled by default]
     memset ( &email_array[0], 0, sizeof(struct ctp_email_r_unload_str) );
     ^
ln -f -s /source/ms/include/ftp_elit.h .
proc CHAR_MAP=STRING ctpdb_unload_ftp.pc INCLUDE=/source/ms/include MODE=ANSI

Pro*C/C++: Release 19.0.0.0.0 - Production on Thu Sep 26 08:47:45 2019
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

System default option values taken from: /usr/lib/oracle/19.3/client64/lib/precomp/admin/pcscfg.cfg

cc -c  -I/usr/include -I/source/ms/include -I/opt/java8/include -I/opt/java8/include/linux -L/source/ms/lib -L/source/ms/lib -L/lib64 -L/opt/java8/jre/lib/amd64/server -L/opt/java8/jre/lib/amd64 -L/usr1/MS/fiorano_libs/clients/c/native/lib -L/usr/lib/oracle/19.3/client64/lib -L/usr/lib/oracle/19.3/client64/lib/lib -lm -lc -lsqlplus -lclntsh -lnet -ljvm -lms -lfmq-crtl ctpdb_unload_ftp.c ctp.h ctp_types.h ctp_str.h
ctpdb_unload_ftp.c: In function ctpdb_unload_ftp:
ctpdb_unload_ftp.c:357:5: warning: incompatible implicit declaration of built-in function memset [enabled by default]
     memset ( &ftp_array[0], 0, sizeof(struct ctp_ftp_tp_unload_str) );
     ^
proc CHAR_MAP=STRING ctpdb_unload_ot.pc INCLUDE=/source/ms/include MODE=ANSI

Pro*C/C++: Release 19.0.0.0.0 - Production on Thu Sep 26 08:47:46 2019
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

System default option values taken from: /usr/lib/oracle/19.3/client64/lib/precomp/admin/pcscfg.cfg

cc -c  -I/usr/include -I/source/ms/include -I/opt/java8/include -I/opt/java8/include/linux -L/source/ms/lib -L/source/ms/lib -L/lib64 -L/opt/java8/jre/lib/amd64/server -L/opt/java8/jre/lib/amd64 -L/usr1/MS/fiorano_libs/clients/c/native/lib -L/usr/lib/oracle/19.3/client64/lib -L/usr/lib/oracle/19.3/client64/lib/lib -lm -lc -lsqlplus -lclntsh -lnet -ljvm -lms -lfmq-crtl ctpdb_unload_ot.c ctp.h ctp_types.h ctp_str.h
ctpdb_unload_ot.c: In function unload_addr_ansi:
ctpdb_unload_ot.c:611:5: warning: incompatible implicit declaration of built-in function memset [enabled by default]
     memset ( &addr_ansi_array[0], 0, sizeof(struct ot_aa_unload_str) );
     ^
ctpdb_unload_ot.c: In function unload_addr_edifact:
ctpdb_unload_ot.c:911:5: warning: incompatible implicit declaration of built-in function memset [enabled by default]
     memset ( &addr_edifact_array[0], 0, sizeof(struct ot_ae_unload_str) );
     ^
ctpdb_unload_ot.c: In function unload_addr_gtdi:
ctpdb_unload_ot.c:1264:5: warning: incompatible implicit declaration of built-in function memset [enabled by default]
     memset ( &addr_gtdi_array[0], 0, sizeof(struct ot_ag_unload_str) );
     ^
ctpdb_unload_ot.c: In function unload_addr_std_int:
ctpdb_unload_ot.c:1548:5: warning: incompatible implicit declaration of built-in function memset [enabled by default]
     memset ( &addr_asi_array[0], 0, sizeof(struct ot_asi_unload_str) );
     ^
ctpdb_unload_ot.c: In function unload_addr_std_int_alias:
ctpdb_unload_ot.c:1952:5: warning: incompatible implicit declaration of built-in function memset [enabled by default]
     memset ( &addr_alias_array[0], 0, sizeof(struct ot_alias_unload_str) );
     ^
ctpdb_unload_ot.c: In function unload_document:
ctpdb_unload_ot.c:2254:5: warning: incompatible implicit declaration of built-in function memset [enabled by default]
     memset ( &doc_array[0], 0, sizeof(struct ot_doc_unload_str) );
     ^
ctpdb_unload_ot.c: In function unload_cr_number:
ctpdb_unload_ot.c:2536:5: warning: incompatible implicit declaration of built-in function memset [enabled by default]
     memset ( &crn_array[0], 0, sizeof(struct ot_crn_unload_str) );
     ^
ctpdb_unload_ot.c:2696:13: warning: incompatible implicit declaration of built-in function strncpy [enabled by default]
             strncpy(crn_array[0].max_value," 99999999999999",15);
             ^
ctpdb_unload_ot.c:2701:13: warning: incompatible implicit declaration of built-in function strncpy [enabled by default]
             strncpy(crn_array[0].max_value,"  9999999999999",15);
             ^
ctpdb_unload_ot.c: In function unload_ic_envelope_in:
ctpdb_unload_ot.c:2897:5: warning: incompatible implicit declaration of built-in function memset [enabled by default]
     memset ( &ici_array[0], 0, sizeof(struct ot_ici_unload_str) );
     ^
ctpdb_unload_ot.c: In function unload_ic_envelope_out:
ctpdb_unload_ot.c:3197:5: warning: incompatible implicit declaration of built-in function memset [enabled by default]
     memset ( &ico_array[0], 0, sizeof(struct ot_ico_unload_str) );
     ^
ctpdb_unload_ot.c: In function unload_fg_envelope_in:
ctpdb_unload_ot.c:3751:5: warning: incompatible implicit declaration of built-in function memset [enabled by default]
     memset ( &fgi_array[0], 0, sizeof(struct ot_fgi_unload_str) );
     ^
ctpdb_unload_ot.c: In function unload_fg_envelope_out:
ctpdb_unload_ot.c:4142:5: warning: incompatible implicit declaration of built-in function memset [enabled by default]
     memset ( &fgo_array[0], 0, sizeof(struct ot_fgo_unload_str) );
     ^
ctpdb_unload_ot.c: In function unload_tp_rship:
ctpdb_unload_ot.c:5071:5: warning: incompatible implicit declaration of built-in function memset [enabled by default]
     memset ( &tp_array[0], 0, sizeof(struct ot_tp_unload_str) );
     ^
ctpdb_unload_ot.c:5580:17: warning: incompatible implicit declaration of built-in function strcpy [enabled by default]
                 strcpy ( tp_array[0].doc_prty_num, "750" );
                 ^
ctpdb_unload_ot.c: In function unload_tp_rship_copy:
ctpdb_unload_ot.c:6278:5: warning: incompatible implicit declaration of built-in function memset [enabled by default]
     memset ( &tpc_array[0], 0, sizeof(struct ot_tpc_unload_str) );
     ^
cc ctpdb.o ctpdb_unload_x400.o   \
ctpdb_unload_email.o  \
ctpdb_unload_ftp.o    \
ctpdb_unload_ot.o     \
ctp_gen.o  -I/usr/include -I/source/ms/include -I/opt/java8/include -I/opt/java8/include/linux -L/source/ms/lib -L/source/ms/lib -L/lib64 -L/opt/java8/jre/lib/amd64/server -L/opt/java8/jre/lib/amd64 -L/usr1/MS/fiorano_libs/clients/c/native/lib -L/usr/lib/oracle/19.3/client64/lib -L/usr/lib/oracle/19.3/client64/lib/lib -lm -lc -lsqlplus -lclntsh -lnet -ljvm -lms -lfmq-crtl  -o ctpdb

Open in new window

2) relevant output of program - you see it is before calling the extern function, but it is never getting there... it is throwing memory fault:
TIMVDS - after do_startup
TIMVDS - before ctp_gen_setup_test_flags
Memory fault

Open in new window

Ok hold on a bit, I got into the external function now ...

TIMVDS - in ctp_gen_setup_test_flags 1
Memory fault

Open in new window


Will post where it fails now if I get to debug it further...
the warnings "incompatible implicit declaration ..." come if you don't include the right header file before.

you may try

#include <string.h>

Open in new window


// if that doesn't help for all, try
#include <unistd.h>
#include <stdlib.h>

warning: "BOOLEAN" redefined

try the following in your sources (or in sources where the 'redefine' message comes)

#ifndef BOOLEAN
#define BOOLEAN int
#define BOOLEAN_DEFINED
#endif

// put here all code from first usage of BOOLEAN type to last usage

#ifdef BOOLEAN_DEFINED
#undef BOOLEAN
#undef BOOLEAN_DEFINED
#endif

Open in new window


or - maybe better - replace BOOLEAN by int in all sources.

then, you may replace TRUE by OK and FALSE by NOT_OK  (only in your sources).

define OK and NOT_OK in a header which was included by all your sources.


ctp_gen_setup_test_flags
try to compile ctp_gen from command_line

if ok, check the ctp_gen.o with a hex editor. the symbol "ctp_gen_setup_test_flags" should be found in the file and shouldn't have longer prefixes or suffixes.

can you show the full prototype of ctp_gen_setup_test_flags both in ctp_gen.h  and your c file.

also post implementation of ctp_gen_setup_test_flags which should be in ctp_gen.pc


Sara
Thanks!  That solved lots of the compiler warnings.

Further debugging shows there is a problem passing on the command line parm.

I run the code as:

ms.vma1:/source/ms/ctp/ctporig> ctpdb 265

Open in new window


I get as output:
TIMVDS - before ctp_gen_setup_test_flags - parms argc : 2
TIMVDS - before ctp_gen_setup_test_flags - parms argv begin :
ctpdb(null)_=*27331*ctpdbCCPATH=/data5/odexccCLASSPATH=/usr1/MS/java/internal/common.jar:/usr1/MS/java/internal/generic8.jar:/usr1/MS/java/internal/generic.jar:/usr1/MS/java/internal/oid.jar:/source/ms/java/oid/oid.jar:/usr1/MS/java/internal/struct.jar:/usr1/MS/java/internal/ebp.jar:/usr1/MS/java/internal/hmrc.jar:/usr1/MS/java/internal/mq.jar:/usr1/MS/java/internal/odex.jar:/usr1/MS/java/internal/fnameserver.jar:/usr1/MS/java/internal/sftp.jar:/usr1/MS/java/internal/sftp_chroot.jar:/usr1/MS/java/internal/tracking.jar:/usr1/MS/java/internal/pipe2jms.jar:/usr1/MS/java/internal/jco.jar:/usr1/MS/java/internal/ftp_in_gencomms_interface.jar:/usr1/MS/java/internal/monitor.jar:/source/ms/java/router/router.jar:/usr1/MS/java/internal/router.jar:/usr1/MS/java/internal/monitor_tracking.jar:/usr1/MS/java/internal/as2tracking.jar:/usr1/MS/java/internal/smuttest.jar:/usr1/MS/java/external/javamail/javamail-1.4.4/activation.jar:/usr1/MS/java/external/javamail/javamail-1.4.4/mail.jar:/usr1/MS/java/external/javamail/javamail-1.4.4/lib/dsn.jar:/usr1/MS/java/external/javamail/javamail-1.4.4/lib/imap.jar:/usr1/MS/java/external/javamail/javamail-1.4.4/lib/mailapi.jar:/usr1/MS/java/external/javamail/javamail-1.4.4/lib/pop3.jar:/usr1/MS/java/external/javamail/javamail-1.4.4/lib/smtp.jar:/usr1/MS/java/external/apache/xalan.jar:/usr1/MS/java/external/apache/xerces.jar:/usr1/MS/java/external/apache/commons-codec-1.3.jar:/usr1/MS/java/external/apache/commons-io-2.6.jar:/usr1/MS/java/external/apache/fop-0.93/build/fop.jar:/usr1/MS/java/external/apache/fop-0.93/lib/avalon-framework-4.2.0.jar:/usr1/MS/java/external/apache/fop-0.93/lib/xmlgraphics-commons-1.1.jar:/usr1/MS/java/external/apache/fop-0.93/lib/serializer-2.7.0.jar:/usr1/MS/java/external/apache/fop-0.93/lib/commons-logging-1.0.4.jar:/usr1/MS/java/external/apache/fop-0.93/lib/commons-io-1.1.jar:/usr1/MS/java/external/apache/fop-0.93/lib/xml-apis-1.3.02.jar:/usr1/MS/java/external/apache/fop-0.93/lib/xercesImpl-2.7.1.jar:/usr1/MS/java/external/apache/fop-0.93/lib/xalan-2.7.0.jar:/usr1/MS/java/external/apache/fop-0.93/lib/batik-all-1.6.jar:/usr1/MS/java/external/oracle/classes12.jar:/usr1/MS/java/external/oracle/ucp.jar:/usr1/sapjco/sapjco3.jar:/usr1/sapjco/sapidoc3.jar:/usr1/MS/java/external/FioranoMQ10.3.0/fmq-client.jar:/usr1/MS/java/external/FioranoMQ10.3.0/fiorano-framework.jar:/usr1/MS/java/external/FioranoMQ10.3.0/jms-2.0.jar:/usr1/MS/java/external/apache/slf4j-1.7.25/slf4j-api-1.7.25.jar:/usr1/MS/java/external/apache/log4j-1.2.17.jar:/usr1/MS/java/external/apache/slf4j-1.7.25/slf4j-nop-1.7.25.jar:/usr1/MS/java/external/javolution/javolution-core-java-6.0.1-20130819.063134-2.jar:/usr1/MS/java/external/javolution/javolution-core-java-6.0.1-20130821.214558-3.jar:/usr1/MS/java/external/javolution/javolution-core-java-6.0.1-20130823.205139-4.jar:/usr1/MS/java/external/javolution/javolution-core-java-6.0.1-20130830.160118-5.jar:/usr1/MS/java/external/javolution/javolution-core-java-6.0.1-20130909.140739-6.jar:/usr1/MS/java/external/nCipher/tti.jar:/usr1/MS/java/external/tumbleweed/jvatk1.7/lib/jvatk.jar:/usr1/MS/java/external/ibm/com.ibm.mq.jar:/usr1/MS/java/external/ibm/com.ibm.mq.pcf-6.1.jar:/usr1/MS/java/external/ibm/connector.jar:/opt/mqm/java/lib/com.ibm.mqbind.jar:/usr1/MS/java/external/javolution/javolution-core-java-6.0.1-20130819.063134-2.jar:javolution-core-java-6.0.1-20130821.214558-3.jar:javolution-core-java-6.0.1-20130823.205139-4.jar:javolution-core-java-6.0.1-20130830.160118-5.jar:javolution-core-java-6.0.1-20130909.140739-6.jar:/usr1/MS/java/external/j2ssh/j2ssh.0.2.9.updated.jar:/usr1/MS/java/external/j2ssh/lib/xmlParserAPIs.jar:/usr1/MS/java/external/j2ssh/lib/xercesImpl.jar:/usr1/MS/java/external/j2ssh/lib/jce-jdk13-119.jar:/usr1/MS/java/external/j2ssh/lib/commons-logging.jarCONFIG_PATH=/usr1/MS/config/config.dataEDITOR=/usr/bin/viHISTCONTROL=ignoredupsHISTSIZE=1000HOME=/home/bes/msHOST=vma1HOSTNAME=vma1JAVA_HOME=/opt/java8JRE_HOME=/opt/java8/jreLANG=en_US.UTF-8LD_LIBRARY_PATH=/usr/lib/oracle/19.3/client64/lib:/usr/dt/lib:/usr/lib64:/usr/lib/oracle/19.3/client64/lib:/usr1/MS/java/lib:/usr/lib64:/usr/dt/lib:/usr/lib/oracle/19.3/client64/lib:/usr/lib/oracle/19.3/client64/rdbms/lib:/usr/lib/oracle/19.3/client64:/usr/lib/oracle/19.3/client64/client_1/lib:/opt/java8/jre/lib/amd64/server/:/opt/java8/jre/lib/amd64:/usr1/MS/fiorano_libs32/clients/c/native/lib/:/usr1/MS/fiorano_libs/clients/c/native/lib/:/usr/java/jdk1.8.0_211-amd64/jre/lib/amd64/:/usr/java/jdk1.8.0_211-amd64/jre/lib/amd64/server/LESSOPEN=||/usr/bin/lesspipe.sh %sLOGNAME=msLS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:MAIL=/var/spool/mail/msMS_BIN=/usr1/MS/binMS_CLOSE=/usr1/MS/dbaMS_CONFIG=/usr1/MS/configMS_DATA1=/data1MS_DEBUG_LOG_LOCATION=/data1/logMS_JAVA=/usr1/MS/javaMS_JAVA_ROOT=/usr1/MS/javaMS_JAVA_SOURCE=/source/ms/javaMS_LOG=/usr1/MS/logMS_OTPROD=/usr1/ai5/prodMS_OTTEST=/usr1/ai5/prodGMS_PROD=/usr1/MSMS_REPORTS=/usr1/MS/reportsMS_ROOT=/source/msMS_SHARE=/nfs5MS_UTIL=/usr1/MS/utilNLS_DATE_FORMAT=DD-MON-YYYY HH24:MI:SSNLS_LANG=AMERICAN.WE8ISO8859P1ORACLE_BASE=/usr/lib/oracleORACLE_HOME=/usr/lib/oracle/19.3/client64OT_DIR_50_INSTALL=/usr1/AI5:/usr1/AI5G:/usr1/ai5/prodPATH=/opt/ssh/bin:/usr1/MS/bin:/usr1/MS/util:/usr1/MS/reports:.:/usr/local/bin:/usr/contrib/bin:/home/bes/ms/bin:/source/ms/util/q:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:.:/usr1/Razor_4.3d/bin:/usr/lib/oracle/19.3/client64/bin:/data5/odexcc:/usr1/ai5/prod/bin:/usr1/ai5/prodG/bin:/opt/java8/bin:/home/bes/ms/lindaPLATFORM=A1PS1=ms.vma1:$PWD> PWD=/source/ms/ctp/ctporigSHELL=/bin/kshSHLIB_PATH=/usr/lib/oracle/19.3/client64/lib:/usr/dt/lib:/usr/lib64:/usr1/ai5/prod/bin:/usr1/ai5/prodG/bin:/usr1/MS/java/lib:/usr1/sapjco/:/usr1/MS/java/lib:/opt/java8/jre/lib/amd64:/opt/java8/jre/lib/amd64/servMemory fault

Open in new window


The relevant bit of code is:
       /* Setup test flags based on command lines parameters */
        printf("TIMVDS - before ctp_gen_setup_test_flags - parms argc : %d \n", argc);
        printf("TIMVDS - before ctp_gen_setup_test_flags - parms argv begin :\n");
        int i;
        for(i=0;i<argc-1;i++)
        {
          printf("%s",argv[i]);
        }
        printf("TIMVDS - before ctp_gen_setup_test_flags - parms argv end\n");
        ctp_gen_setup_test_flags ( argc,
                                   argv,
                                   & msg_to_test,
                                   & subsystem_to_test,
                                   & file_to_test );

Open in new window

for(i=0;i<argc-1;i++)

use

printf("argc = %d\n", argc);
for (i = 0; i < argc; ++i)
printf("%d %s\n",i, argv[ i ]);

Open in new window


it seems as the argc is corrupted. if so, the program wasn't successfully built.

the last valid argument to print is argv[argc-1] while your loop misses the last argument.

please post the  ctp_gen_setup_test_flags prototype from the extern statement and fom ctp_gen.h.

also the function body from ctp_gen.pc.

Sara
Odd code, I must admit ... not sure what the prior developer was trying to do here, empty the arguments parm??? ... but it worked on the other machine ...

Function in ctp_gen.pc that crashes:
extern void ctp_gen_setup_test_flags ( int argc,
                                       char *argv[],
                                       int *msg_to_test,
                                       subsystem_type *subsystem_to_test,
                                       file_types     *file_to_test )
{
    printf("TIMVDS - in ctp_gen_setup_test_flags 1\n");
    char* c = argv[2],
          text[512];

    int i;

    printf("TIMVDS - in ctp_gen_setup_test_flags 2\n");
    if ( argc < 2 )
    {
        /* If no parameters are passed then we are not testing any particular
           message or subsystem */

    printf("TIMVDS - in ctp_gen_setup_test_flags 3a\n");
        *msg_to_test = 0 ;
        *subsystem_to_test = no_subtype ;
        *file_to_test = all_files ;
    printf("TIMVDS - in ctp_gen_setup_test_flags 4a\n");
    }
    else
    {
        /* Checking that the sub-type input is in lowercase PM */

    printf("TIMVDS - in ctp_gen_setup_test_flags 3b print arguments : %s\n", c);
        while (*c != '\0')
        {
    printf("TIMVDS - in ctp_gen_setup_test_flags 3b in loop...\n");
            *c++=tolower(*c);
        }

    printf("TIMVDS - in ctp_gen_setup_test_flags 4b\n");
        *msg_to_test = atoi ( argv [ 1 ] ) ;
        *file_to_test = all_files ;

    printf("TIMVDS - in ctp_gen_setup_test_flags 5b\n");
        if ( argc > 2 )
        {
            if ( 0 == strcmp (argv[2], "x400" ) )
                *subsystem_to_test = x400 ;

            else if ( 0 == strcmp (argv[2], "ftp" ) )
                *subsystem_to_test = ftp ;

            else if ( 0 == strcmp (argv[2], "email" ) )
                *subsystem_to_test = email ;

            else if ( 0 == strcmp (argv[2], "ot" ) )
                *subsystem_to_test = ot ;
            else
            {
                *subsystem_to_test = no_subtype ;
                sprintf(text, "Subsystem type %s not recognised. Recognised systems are : x400, ftp, email or ot\n",
                                    argv[2] ) ;
                logSEM(MSEERR, INFORMATIONAL, text);
            }
        }
    printf("TIMVDS - in ctp_gen_setup_test_flags 6b\n");

        if ( argc > 3 && *subsystem_to_test != no_subtype )
        {
            if ( 0 == strcmp ( argv [ 3 ], "x400_busent_comms" ) )
                *file_to_test = x400_busent_comms ;

            else if ( 0 == strcmp ( argv [ 3 ], "ftp_tp_rship" ) )
                *file_to_test = ftp_tp_rship ;

            else if ( 0 == strcmp ( argv [ 3 ], "ftp_ip_details" ) )
                *file_to_test = ftp_ip_details ;

            else if ( 0 == strcmp ( argv [ 3 ], "email_r" ) )
                *file_to_test = email_r ;

            else if ( 0 == strcmp ( argv [ 3 ], "email_s" ) )
                *file_to_test = email_s ;

            else if ( 0 == strcmp ( argv [ 3 ], "ot_addr_edifact" ) )
                *file_to_test = ot_addr_edifact ;

           else if ( 0 == strcmp ( argv [ 3 ], "ot_addr_ansi" ) )
                *file_to_test = ot_addr_ansi ;

            else if ( 0 == strcmp ( argv [ 3 ], "ot_addr_gtdi" ) )
                *file_to_test = ot_addr_gtdi ;

            else if ( 0 == strcmp ( argv [ 3 ], "ot_addr_std_int" ) )
                *file_to_test = ot_addr_std_int ;

            /* Issue 139  */
            else if ( 0 == strcmp ( argv [ 3 ], "ot_addr_std_int_alias" ) )
                *file_to_test = ot_addr_std_int_alias ;

            else if ( 0 == strcmp ( argv [ 3 ], "ot_document" ) )
                *file_to_test = ot_document ;

            else if ( 0 == strcmp ( argv [ 3 ], "ot_cr_number" ) )
                *file_to_test = ot_cr_number ;

            else if ( 0 == strcmp ( argv [ 3 ], "ot_ic_envelope_in" ) )
                *file_to_test = ot_ic_envelope_in ;
            else if ( 0 == strcmp ( argv [ 3 ], "ot_ic_envelope_out" ) )
                *file_to_test = ot_ic_envelope_out ;

            else if ( 0 == strcmp ( argv [ 3 ], "ot_fg_envelope_in" ) )
                *file_to_test = ot_fg_envelope_in ;

            else if ( 0 == strcmp ( argv [ 3 ], "ot_fg_envelope_out" ) )
                *file_to_test = ot_fg_envelope_out ;

            else if ( 0 == strcmp ( argv [ 3 ], "ot_tp_rship" ) )
                *file_to_test = ot_tp_rship ;

            else if ( 0 == strcmp ( argv [ 3 ], "ot_tp_rship_copy" ) )
                *file_to_test = ot_tp_rship_copy ;

            else
            {
                *file_to_test = all_files ;
                DEBUGOUT ( printf( "File type %s not recognised to test\n",
                                    argv [ 3 ] ) ) ;
            }

        }
    }
}

Open in new window



ctpdb.pc first lines until crash:
int main ( int  *argc, char *argv[] )
{
    int q_ctpdb_id;

    ctpdb_config_ptr ctpdb_config;

    int status = SUCCESS;
    int msg_to_test;
    subsystem_type subsystem_to_test;
    file_types file_to_test;

    BOOLEAN shutdown_flag;

    /* Check the there is a database installed on the machine CTPDB is running
       on.  If not then simply shutdown gracefully */

    if ( FALSE == running_on_server() )
        exit ( 0 );

        printf("TIMVDS - before do_startup - parms argv begin :\n");
        printf("%s\n",argv[0]);
        printf("%s\n",argv[1]);
        printf("TIMVDS - before do_startup - parms argv end\n");

    /* Do all the startup operations for the process */

    status = do_startup ( argv[1], &q_ctpdb_id,
                                   &ctpdb_config );

    if ( SUCCESS == status )
    {
        /* Setup test flags based on command lines parameters */
        printf("TIMVDS - before ctp_gen_setup_test_flags - parms argc : %d \n", argc);
        printf("TIMVDS - before ctp_gen_setup_test_flags - parms argv begin :\n");
        printf("%s\n",argv[0]);
        printf("%s\n",argv[1]);
        printf("TIMVDS - before ctp_gen_setup_test_flags - parms argv end\n");
        ctp_gen_setup_test_flags ( argc,
                                   argv,
                                   & msg_to_test,
                                   & subsystem_to_test,
                                   & file_to_test );

Open in new window


do_startup function:
/*---------------------------------------------------------------------------*/

static short do_startup ( char             *param_1,
                          int              *q_ctpdb_id,
                          ctpdb_config_ptr *ctpdb_config )
{

     printf("TIMVDS - in do_startup 1 - parms argv param_1 : %s\n", param_1);
    /* Do various startup operations, like get queue ids, and stuff */

    char q_ctpdb_path [ MSPATHLEN + MSFILELEN + 1 ];
    char q_ctp_path [ MSPATHLEN + MSFILELEN + 1 ];

    char process_code [ 10 ];
    int status;

    DEBUGOUT ( printf ( "CTPDB starting up\n" ) );

     printf("TIMVDS - in do_startup 2 - parms argv param_1 : %s\n", param_1);
    logSEM ( MSEINF, STARTUPMSG );

    /* If the first parameter passed in is a number between 1 and 99 then
       it is a message number, otherwise it is a process number */

    if ( 'D' == param_1[0] )
    {
        debugging = TRUE;
        param_1[0] = '0';
    }

     printf("TIMVDS - in do_startup 3 - parms argv param_1 : %s\n", param_1);
    if ( ( atoi ( param_1 ) > 0 ) & ( atoi ( param_1 ) < 100 ) )
    {
        strcpy ( process_code, "2000" );
     printf("TIMVDS - in do_startup 3a - parms argv param_1 : %s\n", param_1);

    }
    else if ( param_1 == 0 )
    {
        strcpy ( process_code, "2000" );

        if ( FALSE == debugging )
            background();
     printf("TIMVDS - in do_startup 3b - parms argv param_1 : %s\n", param_1);
    }
    else
    {
        strcpy ( process_code, param_1 );

        /* Blank out param_1 so it is not used as a test message */

        strcpy ( param_1, "" );

        /* if not doing a test then put the process into the background */

        if ( FALSE == debugging )
            background();
     printf("TIMVDS - in do_startup 3c - parms argv param_1 : %s\n", param_1);
    }

     printf("TIMVDS - in do_startup 4 - parms argv param_1 : %s\n", param_1);
    /* initialise general program variables */

    status = ( GENSUCCESS == msinitproc ( process_code, "CTPDB" ) );

    if ( SUCCESS == status )
    {
        /* initialise general program variables */

        *ctpdb_config = ( ctpdb_config_ptr ) malloc (sizeof(ctpdb_config_str));

        if ( FAILURE == ( status = ( NULL != *ctpdb_config ) ) )
            logSEM ( MSEFAT, MALLOCFAIL, sizeof ( ctpdb_config_str ),
                                         errno, strerror ( errno )   );
    }

     printf("TIMVDS - in do_startup 5 - parms argv param_1 : %s\n", param_1);
    /* Load the config structure with ctpdb config parameters */

    if ( SUCCESS == status )
        status = initialise_config ( *ctpdb_config );

    if ( SUCCESS == status )
    {
        DEBUGOUT ( printf ( "CTPDB initialised\n" ) );

        /* Get pathname of the CTPDB queue */

        status = ( GCSUCCESS == lgetconf ( "Q_CTPDB", q_ctpdb_path, 0 ) );

        if ( SUCCESS == status )
        {
            /* Attatch to CTPDB queue */

            *q_ctpdb_id = Q_attachgen ( q_ctpdb_path );

            status = ( 0 < *q_ctpdb_id ) ;

            if ( SUCCESS == status )
                DEBUGOUT ( printf ( "CTPDB attatched to CTPDB queue\n" ) );
        }
    }

     printf("TIMVDS - in do_startup 6 - parms argv param_1 : %s\n", param_1);
    /* Load the config structure with ctpdb config parameters */
    if ( SUCCESS == status )
    {
        /* Empty out any old CTPDB messages still in the queue *.

        status = ctp_gen_empty_queue ( *q_ctpdb_id );
    }

    if ( SUCCESS == status )
    {
        /* Get pathname of the CTP queue */

        status = ( GCSUCCESS == lgetconf ( "Q_CTP", q_ctp_path, 0 ) );

        if ( SUCCESS == status )
        {
            /* Attatch to CTP queue */

            (*ctpdb_config)->q_ctp_id = Q_attachgen ( q_ctp_path );

            status = ( 0 < (*ctpdb_config)->q_ctp_id ) ;

            if ( SUCCESS == status )
                DEBUGOUT ( printf ( "CTPDB attatched to CTP queue\n" ) );
        }
    }
     printf("TIMVDS - in do_startup 7 - parms argv param_1 : %s\n", param_1);
    if ( SUCCESS == status )
    {
        /* Connect to the database */

        status = ( TRUE == connect_to_database ( (*ctpdb_config)->ms_db_name,
                                       (*ctpdb_config)->unload_blocking ) );
    }

     printf("TIMVDS - in do_startup 8 - parms argv param_1 : %s\n", param_1);
    return ( status );
}

Open in new window


Generated output:
ms.vma1:/source/ms/ctp/ctporig> ctpdb 265
TIMVDS - before do_startup - parms argv begin :
ctpdb
265
TIMVDS - before do_startup - parms argv end
TIMVDS - in do_startup 1 - parms argv param_1 : 265
TIMVDS - in do_startup 2 - parms argv param_1 : 265
----------------------------------------------------------
LOGSEM_DEBUG - in Q.c in logSEM to see where we lose the 2 initial chars.
LOGSEM_DEBUG - in Q.c in logSEM print out buffer 26/09/19 15:26:04 vma1  00000 INFO 00101 Starting and msglen 49
26/09/19 15:26:04 vma1  00000 INFO 00101 Starting
TIMVDS - in do_startup 3 - parms argv param_1 : 265
TIMVDS - in do_startup 3c - parms argv param_1 :
TIMVDS - in do_startup 4 - parms argv param_1 :
mzlbzl - BEGIN msattqlog in genlib.c waar qlogpath wordt gebruikt :
1 getconf.c getlogpath INFO-DZDSNP - MSQLOGPATH is: Q_LOG, qlogpath is .
attachmsQlog INFO-DZDSNP - qlogpath is: /data1/ftp/ftprd/in/Q_LOG, qmslogidG is -1.
BEGIN Q attach G_queue_type = 2 (NATIVE_JMS_Q_TYPE is 4)
mzlbzl - IN Q_Uattach waar qid wordt returned voor path /data1/ftp/ftprd/in/Q_LOG : 0
mzlbzl - END msattqlog in genlib.c waar qlogpath wordt gebruikt : /data1/ftp/ftprd/in/Q_LOG
mzlbzl - BEGIN trattqlog in genlib.c waar qlogpath wordt gebruikt :
mzlbzl - IN gettrlogpath waar JQLOGDPATH opgehaald Q_JLOGD
1 getconf.c gettrlogpath INFO-DZDSNP - JQLOGDPATH is: Q_JLOGD, qlogpath is .
attachQlog mzlbzl BEFORE attaching qlogidG - qlogpath is: /usr1/MS/q/Q_JLOGD
BEGIN Q attach G_queue_type = 2 (NATIVE_JMS_Q_TYPE is 4)
mzlbzl - IN Q_Uattach waar qid wordt returned voor path /usr1/MS/q/Q_JLOGD : 65538
attachQlog mzlbzl FOR qlogidG - qlogpath is: /usr1/MS/q/Q_JLOGD, qlogidG is 65538.
mzlbzl - END trattqlog in genlib.c waar qlogpath wordt gebruikt : /usr1/MS/q/Q_JLOGD
TIMVDS - in do_startup 5 - parms argv param_1 :
----------------------------------------------------------
LOGSEM_DEBUG - in Q.c in logSEM to see where we lose the 2 initial chars.
LOGSEM_DEBUG - in Q.c in logSEM print out buffer 26/09/19 15:26:04 vma1 CTPDB 00265 INFO 90050 Parameters read from config file and msglen 78
BEGIN Q attach G_queue_type = 2 (NATIVE_JMS_Q_TYPE is 4)
mzlbzl - IN Q_Uattach waar qid wordt returned voor path /usr1/MS/q/Q_CTPDB : 557073
----------------------------------------------------------
LOGSEM_DEBUG - in Q.c in logSEM to see where we lose the 2 initial chars.
LOGSEM_DEBUG - in Q.c in logSEM print out buffer 26/09/19 15:26:04 vma1 CTPDB 00265 INFO 20014 Q_attach() succeeded, Key = /usr1/MS/q/Q_CTPDB, Qid = 557073 and msglen 106
TIMVDS - in do_startup 6 - parms argv param_1 :
BEGIN Q attach G_queue_type = 2 (NATIVE_JMS_Q_TYPE is 4)
mzlbzl - IN Q_Uattach waar qid wordt returned voor path /usr1/MS/q/Q_CTP : 524304
----------------------------------------------------------
LOGSEM_DEBUG - in Q.c in logSEM to see where we lose the 2 initial chars.
LOGSEM_DEBUG - in Q.c in logSEM print out buffer 26/09/19 15:26:04 vma1 CTPDB 00265 INFO 20014 Q_attach() succeeded, Key = /usr1/MS/q/Q_CTP, Qid = 524304 and msglen 104
TIMVDS - in do_startup 7 - parms argv param_1 :
TIMVDS - in do_startup 8 - parms argv param_1 :
TIMVDS - before ctp_gen_setup_test_flags - parms argc : 2
TIMVDS - before ctp_gen_setup_test_flags - parms argv begin :
ctpdb

TIMVDS - before ctp_gen_setup_test_flags - parms argv end
TIMVDS - in ctp_gen_setup_test_flags 1
TIMVDS - in ctp_gen_setup_test_flags 2
TIMVDS - in ctp_gen_setup_test_flags 3b print arguments : (null)
Memory fault

Open in new window

the extern keyword shouldn't be used for the definition of the function in ctp_gen.pc. nevertheless, c normally would accept this function as the implementation. so, if the ctp_gen.pc compiles successfully by using a c compiler AND if the ctp_gen.o was newly built and successfully linked to ctp executable, then it shouldn't crash immediately. so check the timestamp of the ctp_gen.o to see if it really was built. you may compile the source separately at the commandline to see if there are errors.

check your makefile. at line 26 the ctp_gen.o was linked to ctp in a list as last object file. the next command at next line is CC$. i mean to remember that you would need an empty line to separate the object file list from next command. if that was not the case you should get an error message or nothing changed.

char* c = argv[2],

          text[512];

if argc == 2 then argv[2] is out of bounds. what would mean that you only provide one argument (argv[0] is only the executable name "cpt") while the function requires at least 2 arguments. i don't know whether char* c = argv[2] is responsible for the crash, but it is not unlikely.

   if ( argc < 2 )
    {
this statement is too late.

you could do the following:

      
         char* c = (argc > 2)? argv[2] : "";
         char  text[512] = { '\0' };

Open in new window


if this code doesn't crash (at least not immediately after call, put a breakpoint at first statement), then the extern function successfully was linked. but obviously it requires at least 2 or even 3 arguments (see code where argv[3] is used).

Sara
You'll use the chrpath command, rather than chatr.

Or better build using some -rpath conjuration, which will usually be...

-Wl,-rpath,/absolute-path-to-your-library

Open in new window


For each library to search at link time + run time.

Note: Some code builds with special -rpath wrappers, like with ffmpeg, you'll use...

# extend build options as in something like...
$bopts .= "--extra-cflags='-pipe $incs' --extra-ldflags='$rpath $libs'"

Open in new window


Where you must set both a cflags rpath list + ldflags rpath list.
Thanks @David, will try that later

Thanks @Sarah, indeed, the absence of the second parm makes it crash in the linux redhat implementation, did not expect I had to change code to make it work on another system, but here we are...

However it is still messing with me...

I startup the code with following parms:
ctpdb 265
ctp 255

However when I look into the process list it displays the following:
ms.vma1:/home/bes/ms> ps -fums | grep ctp
ms       20501     1  0 07:11 pts/2    00:00:01 ctp  55
ms       20578     1  0 07:11 pts/2    00:00:01 ctpdb  25

It cuts off one char of the parm ...  It also only does that on the new system...

Regards,
Tim
You're welcome!

Parameter cut off can be an indication of memory corruption.

Likely best to do some searching of how to use gdb, then set a break point in gdb on various memory locations to see if you truly have a memory corruption problem or the program logic is incorrectly processing command line options.
Memory corruption??? That sounds like it's never gonna work :(
A free rhel c static analysis check may help you.
http://cppcheck.sourceforge.net/

But this Valgrind is indispensable. Valgrind will help you automatically solve runtime errors. Solves memory corruption problems at its source, not where the program actually crashes later on
http://valgrind.org/

 Here are some problems that it will detect.
http://cs.ecs.baylor.edu/~donahoo/tools/valgrind/messages.html
ASKER CERTIFIED SOLUTION
Avatar of Tim Van der Stighelen
Tim Van der Stighelen

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This caused the parms to be incorrect in the ps list.

ok. but ps list is just a tool and the wrong output wouldn't prevent from running correctly if the code is ok respectively is correctly ported to the new compiler.

this is still messing with me

what is the result of your last attempts passing 2 arguments?

it should add some output lines 3b, 4b, 5b and 6b. the rest of code would apply for 3 or 4 arguments only. it is not quite clear why there are so many (debug?) printf statements which are conditioned by the number of arguments. shouldn't it be enough to print the arguments count and argument strings once in function main? this way the remaining code might be readable at least.

so my idea of just compiling this big program on another environment fades away...

i doubt that the program you posted would run at the original environment if you pass only one or two arguments.

Sara