gnucobol-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [open-cobol-list] linking stuff (statically linked same code)


From: Marty Heyman
Subject: Re: [open-cobol-list] linking stuff (statically linked same code)
Date: Mon, 15 Sep 2014 09:54:20 -0400

Different compile behavior

— START SESSION CLIP —
address@hidden:~/Projects/PlanBTest/mhWork$ cobc -L/usr/lib -lpq -std=mvs -static -x -w ../cobol_source/PGTest.cbl 
/tmp/cob42052_0.c: In function ‘pgcob_’:
/tmp/cob42052_0.c:102:3: warning: implicit declaration of function ‘PQconnectdb’ [-Wimplicit-function-declaration]
   (*(unsigned char **) (b_5)) = (void *)PQconnectdb ((cob_u8_ptr)"dbname = postgres\000");
   ^
/tmp/cob42052_0.c:102:33: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   (*(unsigned char **) (b_5)) = (void *)PQconnectdb ((cob_u8_ptr)"dbname = postgres\000");
                                 ^
/tmp/cob42052_0.c:110:3: warning: implicit declaration of function ‘PQstatus’ [-Wimplicit-function-declaration]
   b_1 = PQstatus ((*(unsigned char **) (b_5)));
   ^
/tmp/cob42052_0.c:119:3: warning: implicit declaration of function ‘PQuser’ [-Wimplicit-function-declaration]
   (*(unsigned char **) (b_7)) = (void *)PQuser ((*(unsigned char **) (b_5)));
   ^
/tmp/cob42052_0.c:119:33: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   (*(unsigned char **) (b_7)) = (void *)PQuser ((*(unsigned char **) (b_5)));
                                 ^
/tmp/cob42052_0.c:140:3: warning: implicit declaration of function ‘PQexec’ [-Wimplicit-function-declaration]
   (*(unsigned char **) (b_6)) = (void *)PQexec ((*(unsigned char **) (b_5)), (cob_u8_ptr)"select version();\000");
   ^
/tmp/cob42052_0.c:140:33: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   (*(unsigned char **) (b_6)) = (void *)PQexec ((*(unsigned char **) (b_5)), (cob_u8_ptr)"select version();\000");
                                 ^
/tmp/cob42052_0.c:150:3: warning: implicit declaration of function ‘PQgetvalue’ [-Wimplicit-function-declaration]
   (*(unsigned char **) (b_7)) = (void *)PQgetvalue ((*(unsigned char **) (b_6)), (cob_s32_t)0LL, (cob_s32_t)0LL);
   ^
/tmp/cob42052_0.c:150:33: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   (*(unsigned char **) (b_7)) = (void *)PQgetvalue ((*(unsigned char **) (b_6)), (cob_s32_t)0LL, (cob_s32_t)0LL);
                                 ^
/tmp/cob42052_0.c:167:3: warning: implicit declaration of function ‘PQfinish’ [-Wimplicit-function-declaration]
   PQfinish ((*(unsigned char **) (b_5)));
   ^
/tmp/cob42052_0.c:185:33: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   (*(unsigned char **) (b_7)) = (void *)PQuser ((*(unsigned char **) (b_5)));
                                 ^
address@hidden:~/Projects/PlanBTest/mhWork$ ./PGTest
Before connect:0x0000000000000000
After connect: 0x0000000000f13590
Status:        +0000000001
User:          marty
call PQexec
0x0000000000000000

Attempt to reference unallocated memory (Signal SIGSEGV)
Abnormal termination - File contents may be incorrect
address@hidden:~/Projects/PlanBTest/mhWork$ 
— END SESSION CLIP ——


Marty Heyman
510-290-6484 (Mobile)



On Sep 15, 2014, at 9:10 AM, Marty Heyman <address@hidden> wrote:

Patrick,
The code is copied below. It is Brian’s example from the FAQ section 5.4.6. I get similar results without -x and running cobcrun (which then can’t find PGTest.so).
I haven’t statically linked stuff yet … will try in a bit. Have a customer on the phone at the moment. 
—— START CODE ——
OCOBOL*> *************************************************************** *> Author: Brian Tiffin *> Date: 20091129 *> Purpose: PostgreSQL connection test *> Tectonics: cobc -x -lpq pgcob.cob *> *************************************************************** identification division. program-id. pgcob. data division. working-storage section. 01 pgconn usage pointer. 01 pgres usage pointer. 01 resptr usage pointer. 01 resstr pic x(80) based. 01 result usage binary-long. 01 answer pic x(80). *> *************************************************************** procedure division. display "Before connect:" pgconn end-display call "PQconnectdb" using by reference "dbname = postgres" & x"00" returning pgconn end-call display "After connect: " pgconn end-display call "PQstatus" using by value pgconn returning result end-call display "Status: " result end-display call "PQuser" using by value pgconn returning resptr end-call set address of resstr to resptr string resstr delimited by x"00" into answer end-string display "User: " function trim(answer) end-display display "call PQexec" end-display call "PQexec" using by value pgconn by reference "select version();" & x"00" returning pgres end-call display pgres end-display *> Pull out a result. row 0, field 0 <* call "PQgetvalue" using by value pgres by value 0 by value 0 returning resptr end-call set address of resstr to resptr string resstr delimited by x"00" into answer end-string display "Version: " answer end-display call "PQfinish" using by value pgconn returning null end-call display "After finish: " pgconn end-display call "PQstatus" using by value pgconn returning result end-call display "Status: " result end-display *> this will now return garbage <* call "PQuser" using by value pgconn returning resptr end-call set address of resstr to resptr string resstr delimited by x"00" into answer end-string display "User after: " function trim(answer) end-display goback. end program pgcob.  
— END CODE — start cobc -v output ———
address@hidden:~/Projects/PlanBTest/mhWork$ cobc -L/usr/lib -lpq -std=mvs -v ../cobol_source/PGTest.cbl 
Command line:	cobc -L/usr/lib -lpq -std=mvs -v ../cobol_source/PGTest.cbl 
Preprocessing:	../cobol_source/PGTest.cbl -> /tmp/cob41797_0.cob
Return status:	0
Parsing:	/tmp/cob41797_0.cob (../cobol_source/PGTest.cbl)
Return status:	0
Translating:	/tmp/cob41797_0.cob -> /tmp/cob41797_0.c (../cobol_source/PGTest.cbl)
Executing:	gcc -std=gnu99 -I/usr/local/include -pipe -Wno-unused
		-fsigned-char -Wno-pointer-sign -shared -fPIC -DPIC
		-Wl,--export-dynamic -o "PGTest.so" "/tmp/cob41797_0.c"
		-L/usr/local/lib -lcob -lm -lgmp -lncurses -ldb -ldl -l"pq"
		-L"/usr/lib"
Return status:	0
address@hidden:~/Projects/PlanBTest/mhWork$
——— END cobc -v output ———
> Patrick wrote
> Hi Marty

> Do you have a little snippet of test code you could share ?

> I am on Debian Stable. I don't seem to be having trouble but maybe I am 
> missing something and have the bug too.

> Is it possible to statically link to see if the problem goes away?

> Could you compile in verbose mode and share?

Thanks

Marty Heyman
510-290-6484 (Mobile)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]